/
githubmirror
/
trpc
Обзор
Документация
Войти
/
githubmirror
/
trpc
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/tests/server/clientInternals.test.ts
31 строка
896 B
Alex / KATT
feat: ability to cancel streamed responses + add `TRPCRequestInfo.signal` (#5865)
11 июл 2024, 00:23
Не верифицирован
11 июл 2024, 00:23
244538d
Код
Авторство
О чём код?
import { getFetch } from '@trpc/client'; describe('getFetch() from...', () => { test('passed', () => { const customImpl: any = () => true; expect(getFetch(customImpl)).toBe(customImpl); }); test('window', () => { (global as any).fetch = undefined; (global as any).window = { fetch: () => 42, }; expect(getFetch()('')).toBe(42); }); test('global', () => { (global as any).fetch = () => 1337; (global as any).window = undefined; delete (global as any).window; expect(getFetch()('')).toBe(1337); }); test('window w. undefined fetch -> global', () => { (global as any).fetch = () => 808; (global as any).window = {}; expect(getFetch()('')).toBe(808); }); test('neither -> throws', () => { (global as any).fetch = undefined; (global as any).window = undefined; expect(() => getFetch()).toThrowError(); }); });