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 20, 2021
1 parent dfe4f29 commit ad87f2b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/__tests__/client.ts
Original file line number Diff line number Diff line change
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 ad87f2b

Please sign in to comment.