Skip to content

Commit

Permalink
Improve spy mocking for queryManager.refetchQueries test.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Apr 30, 2021
1 parent bd03868 commit efc1fe7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/__tests__/client.ts
Expand Up @@ -2428,18 +2428,18 @@ describe('client', () => {
});

it('has a refetchQueries method which calls QueryManager', async () => {
// TODO(dannycochran)
const client = new ApolloClient({
link: ApolloLink.empty(),
cache: new InMemoryCache(),
});

// @ts-ignore
const spy = jest.spyOn(client.queryManager, 'refetchQueries');
await client.refetchQueries({
include: ['Author1'],
});
expect(spy).toHaveBeenCalled();
const spy = jest.spyOn(client['queryManager'], 'refetchQueries');
spy.mockImplementation(() => new Map);

const options = { include: ['Author1'] };
await client.refetchQueries(options);

expect(spy).toHaveBeenCalledWith(options);
});

itAsync('should propagate errors from network interface to observers', (resolve, reject) => {
Expand Down

0 comments on commit efc1fe7

Please sign in to comment.