Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
query: encodedQuery,
variables: { name: 'Love apollo' },
}),
);
expect(fetchMock.called('/api/posts?name=Love%20apollo')).toBe(true);
await makePromise(
execute(link, {
operationName: 'postQuery',
query: mixedQuery,
variables: { id: 1, query: { comments: 5 } },
}),
);
expect(fetchMock.called('/api/posts/1?comments=5')).toBe(true);
});
// TODO: Test for Path using context
fetchMock.mock('/api/videos/43/', deferred.promise);
const { getByText, queryByText, rerender } = render(
wrapInIntlProvider(
wrapInRouter(
,
),
),
);
// DashboardVideoPane shows the video as PROCESSING
getByText('Processing');
getByText(
'Your video is currently processing. This may take up to an hour. Please come back later.',
);
expect(fetchMock.called()).not.toBeTruthy();
// First backend call: the video is still processing
jest.advanceTimersByTime(1000 * 60 + 200);
await act(async () =>
deferred.resolve(JSON.stringify({ ...video, upload_state: PROCESSING })),
);
expect(fetchMock.lastCall()![0]).toEqual('/api/videos/43/');
expect(fetchMock.lastCall()![1]!.headers).toEqual({
Authorization: 'Bearer cool_token_m8',
});
getByText('Processing');
getByText(
'Your video is currently processing. This may take up to an hour. Please come back later.',
);
.then((res) => {
expect(res).toMatchSnapshot();
expect(fetchMock.called(url)).toBeTruthy();
expect(fetchMock.lastUrl()).toBe(url);
expect(fetchMock.lastOptions().method).toBe('get');
});
});
frest.post('testpost', { body }).then((res) => {
if (res) {
expect(fetchMock.called('testpost')).toBe(true);
expect(res.origin.status).toBe(200);
return frest.create('testcreate');
}
return Promise.reject('testpost: no response returned');
}).then((res) => {
if (res) {
await wait();
expect(fetchMock.calls().length).toEqual(0);
fireEvent.change(field, { target: { value: 'xyz' } });
await wait();
expect(
fetchMock.called('/api/v1.0/levels/autocomplete/?query=xyz'),
).toEqual(false);
expect(
fetchMock.called('/api/v1.0/organizations/autocomplete/?query=xyz'),
).toEqual(true);
expect(
fetchMock.called('/api/v1.0/persons/autocomplete/?query=xyz'),
).toEqual(true);
expect(
fetchMock.called('/api/v1.0/subjects/autocomplete/?query=xyz'),
).toEqual(true);
});
it('[resource-label]: fetches ID', async () => {
await setup({ resourceLabel: 'resource-label' });
expect(fetchMock.called(`begin:${graphqlEndpoint}`)).toBe(true);
});
}).catch(result => {
expect(fetchMock.called('path:/v1/test')).toBe(true);
expect(result.message).toEqual(body.message);
});
});