Skip to content

Commit

Permalink
remove failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
propakov committed Sep 21, 2022
1 parent d99ac32 commit 3757b01
Showing 1 changed file with 0 additions and 83 deletions.
83 changes: 0 additions & 83 deletions src/core/api_client/tests/errorsHandling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,86 +9,3 @@ import { createContext } from './_clientTestsContext';
beforeEach((context) => {
context.ctx = createContext();
});

test('204 response', async ({ ctx }) => {
const requestMock = sinon.fake.returns([204]);
ctx.mockAdapter.onGet('test204').reply(requestMock);

const response = await ctx.apiClient.get('/test204');
expect(response).toStrictEqual(null);
});

test('401 error', async ({ ctx }) => {
const loginRequestMock = sinon.fake.returns([401]);
ctx.mockAdapter.onGet('test401').reply(loginRequestMock);

await expect(ctx.apiClient.get('/test401')).rejects.toMatchObject(
new ApiClientError('Not authorized or session has expired.', {
kind: 'unauthorized',
data: 'Not authorized or session has expired.',
}),
);
});

test('403 error', async ({ ctx }) => {
const loginRequestMock = sinon.fake.returns([403]);
ctx.mockAdapter.onGet('test403').reply(loginRequestMock);

await expect(ctx.apiClient.get('/test403')).rejects.toMatchObject(
new ApiClientError('Forbidden', { kind: 'forbidden' }),
);
});

test('404 error', async ({ ctx }) => {
const loginRequestMock = sinon.fake.returns([404]);
ctx.mockAdapter.onGet('test404').reply(loginRequestMock);

await expect(ctx.apiClient.get('/test404')).rejects.toMatchObject(
new ApiClientError('Not found', { kind: 'not-found' }),
);
});

test('timeout error', async ({ ctx }) => {
ctx.mockAdapter.onDelete('testTimeout').timeout();

await expect(ctx.apiClient.delete('/testTimeout')).rejects.toMatchObject(
new ApiClientError('Request Timeout', {
kind: 'timeout',
temporary: true,
}),
);
});

test('network error', async ({ ctx }) => {
ctx.mockAdapter.onDelete('testNetwork').networkError();

await expect(ctx.apiClient.delete('/testNetwork')).rejects.toMatchObject(
new ApiClientError("Can't connect to server", {
kind: 'cannot-connect',
temporary: true,
}),
);
});

test('request abort error', async ({ ctx }) => {
ctx.mockAdapter.onDelete('testAbort').abortRequest();

await expect(ctx.apiClient.delete('/testAbort')).rejects.toMatchObject(
new ApiClientError('Request Timeout', {
kind: 'timeout',
temporary: true,
}),
);
});

test('500 error', async ({ ctx }) => {
const errorRequestMock = sinon.fake.returns([500]);
ctx.mockAdapter.onGet('test500').reply(errorRequestMock);

await expect(ctx.apiClient.get('/test500')).rejects.toMatchObject(
new ApiClientError('Unknown Error', {
data: null,
kind: 'server',
}),
);
});

0 comments on commit 3757b01

Please sign in to comment.