1import { forEach, fromValue, pipe } from 'wonka';
2import { vi, expect, it, beforeEach, afterAll } from 'vitest';
3
4import { queryOperation, teardownOperation } from '../test-utils';
5import { fallbackExchange } from './fallback';
6
7const consoleWarn = console.warn;
8
9const dispatchDebug = vi.fn();
10
11beforeEach(() => {
12 console.warn = vi.fn();
13});
14
15afterAll(() => {
16 console.warn = consoleWarn;
17});
18
19it('filters all results and warns about input', () => {
20 const res: any[] = [];
21
22 pipe(
23 fallbackExchange({ dispatchDebug })(fromValue(queryOperation)),
24 forEach(x => res.push(x))
25 );
26
27 expect(res.length).toBe(0);
28 expect(console.warn).toHaveBeenCalled();
29});
30
31it('filters all results and does not warn about teardown operations', () => {
32 const res: any[] = [];
33
34 pipe(
35 fallbackExchange({ dispatchDebug })(fromValue(teardownOperation)),
36 forEach(x => res.push(x))
37 );
38
39 expect(res.length).toBe(0);
40 expect(console.warn).not.toHaveBeenCalled();
41});