1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-15 15:18:22 +09:00
This commit is contained in:
syuilo 2021-05-23 12:19:39 +09:00
parent bdb592539e
commit 08f673802f

View File

@ -1,4 +1,4 @@
import { APIClient } from '../src/api'; import { APIClient, isAPIError } from '../src/api';
import { enableFetchMocks } from 'jest-fetch-mock'; import { enableFetchMocks } from 'jest-fetch-mock';
enableFetchMocks(); enableFetchMocks();
@ -57,10 +57,12 @@ describe('API', () => {
return { return {
status: 500, status: 500,
body: JSON.stringify({ body: JSON.stringify({
message: 'Internal error occurred. Please contact us if the error persists.', error: {
code: 'INTERNAL_ERROR', message: 'Internal error occurred. Please contact us if the error persists.',
id: '5d37dbcb-891e-41ca-a3d6-e690c97775ac', code: 'INTERNAL_ERROR',
kind: 'server', id: '5d37dbcb-891e-41ca-a3d6-e690c97775ac',
kind: 'server',
},
}) })
}; };
}); });
@ -73,6 +75,7 @@ describe('API', () => {
await cli.request('i'); await cli.request('i');
} catch (e) { } catch (e) {
expect(isAPIError(e)).toEqual(true);
expect(e.id).toEqual('5d37dbcb-891e-41ca-a3d6-e690c97775ac'); expect(e.id).toEqual('5d37dbcb-891e-41ca-a3d6-e690c97775ac');
} }
}); });