Download lib/utils/request-rewriter/get.test.ts from ASEM12345/rsshub: direct link, hf CLI and curl.
- Browser
- Download file 999 Bytes
-
https://huggingface.co/spaces/ASEM12345/rsshub/resolve/main/lib/utils/request-rewriter/get.test.ts
- Command line
-
hf download hf://spaces/ASEM12345/rsshub/lib/utils/request-rewriter/get.test.ts
-
curl -L -o get.test.ts https://huggingface.co/spaces/ASEM12345/rsshub/resolve/main/lib/utils/request-rewriter/get.test.ts
999 Bytes
| 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(() => '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://' } as any; | |
| const result = wrapped(options, callback); | |
| expect(result).toBe('fallback'); | |
| expect(origin).toHaveBeenCalledWith(options, callback); | |
| }); | |
| }); | |