mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-24 02:09:23 +08:00
fc008f7ac8
* feat(route/instagram): rework web-api
* Revert "fix(utils/request-rewriter): pass CONNECT proxy tunnel requests through untouched (#23136)"
This reverts commit d89d20f90f.
* feat: add stories
* fix: update route name
30 lines
1020 B
TypeScript
30 lines
1020 B
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import getWrappedGet from '@/utils/request-rewriter/get';
|
|
|
|
describe('request-rewriter get wrapper', () => {
|
|
it('passes callback when url and callback are provided', () => {
|
|
const origin = vi.fn<(...args: any[]) => string>(() => 'ok');
|
|
const wrapped = getWrappedGet(origin as any);
|
|
const callback = vi.fn();
|
|
|
|
const result = wrapped('http://example.com/test', callback);
|
|
|
|
expect(result).toBe('ok');
|
|
expect(origin).toHaveBeenCalledTimes(1);
|
|
expect(origin.mock.calls[0][2]).toBe(callback);
|
|
});
|
|
|
|
it('falls back to origin when url parsing fails', () => {
|
|
const origin = vi.fn(() => 'fallback');
|
|
const wrapped = getWrappedGet(origin as any);
|
|
const callback = vi.fn();
|
|
const options = { href: 'http://' };
|
|
|
|
const result = wrapped(options, callback);
|
|
|
|
expect(result).toBe('fallback');
|
|
expect(origin).toHaveBeenCalledWith(options, callback);
|
|
});
|
|
});
|