Skip to content

Commit

Permalink
Update tests for type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Mar 16, 2023
1 parent 4b7997a commit 3ce4cb7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions exchanges/persisted/src/persistedExchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ import {
import { Client, Operation, OperationResult, CombinedError } from '@urql/core';

import { vi, expect, it } from 'vitest';
import { queryOperation } from '../../../packages/core/src/test-utils';
import {
queryResponse,
queryOperation,
} from '../../../packages/core/src/test-utils';
import { persistedExchange } from './persistedExchange';

const makeExchangeArgs = () => {
const operations: Operation[] = [];

const result = vi.fn(
(operation: Operation): OperationResult => ({ operation })
(operation: Operation): OperationResult => ({ ...queryResponse, operation })
);

return {
Expand All @@ -33,7 +36,7 @@ const makeExchangeArgs = () => {
tap(op => operations.push(op)),
map(result)
),
client: new Client({ url: '/api' }),
client: new Client({ url: '/api', exchanges: [] }),
} as any,
};
};
Expand Down Expand Up @@ -62,6 +65,7 @@ it('retries query when persisted query resulted in miss', async () => {
const { result, operations, exchangeArgs } = makeExchangeArgs();

result.mockImplementationOnce(operation => ({
...queryResponse,
operation,
error: new CombinedError({
graphQLErrors: [{ message: 'PersistedQueryNotFound' }],
Expand Down Expand Up @@ -91,6 +95,7 @@ it('retries query persisted query resulted in unsupported', async () => {
const { result, operations, exchangeArgs } = makeExchangeArgs();

result.mockImplementationOnce(operation => ({
...queryResponse,
operation,
error: new CombinedError({
graphQLErrors: [{ message: 'PersistedQueryNotSupported' }],
Expand Down

0 comments on commit 3ce4cb7

Please sign in to comment.