Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/unhandled promise rejection warning in sdk tests #101

Merged
merged 2 commits into from
Jun 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ describe('QueryComponentRemoteService', () => {

});

it('should send get request to repository url', () => {
it('should send get request to repository url', async () => {

const service = new QueryComponentRemoteService('test');

const mockFetch = jest.fn().mockImplementation(() => Promise.resolve({
json: () => Promise.resolve({}),
ok: true,
}));

window.fetch = mockFetch;

service.query({});
await service.query({});

expect(fetch).toBeCalledWith('test/component/query', {
body: '{}',
Expand All @@ -33,7 +34,7 @@ describe('QueryComponentRemoteService', () => {

});

it('should throw error when request fails', () => {
it('should throw error when request fails', async () => {

const service = new QueryComponentRemoteService('test');

Expand All @@ -44,25 +45,23 @@ describe('QueryComponentRemoteService', () => {

window.fetch = mockFetch;

service.query({});

expect(fetch).rejects.toThrow();
await expect(service.query({})).rejects.toThrow();

});

it('should throw error when querying if filter is not set', async () => {

const service = new QueryComponentRemoteService('test');

expect(service.query(null)).rejects.toThrow();
await expect(service.query(null)).rejects.toThrow();

});

it('should throw error when querying if repository is not set', async () => {

const service = new QueryComponentRemoteService(null);

expect(service.query({})).rejects.toThrow();
await expect(service.query({})).rejects.toThrow();

});

Expand Down