diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-05-19 14:01:04 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-05-19 14:01:04 +0900 |
| commit | c6088a1cb39d7fb97f0c32a20e2705ebab70177e (patch) | |
| tree | dc6f13d19d00ad528b625ca0cdced723d1afd452 | |
| parent | add comment (diff) | |
| download | misskey-c6088a1cb39d7fb97f0c32a20e2705ebab70177e.tar.gz misskey-c6088a1cb39d7fb97f0c32a20e2705ebab70177e.tar.bz2 misskey-c6088a1cb39d7fb97f0c32a20e2705ebab70177e.zip | |
add test
| -rw-r--r-- | test/api.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/api.ts b/test/api.ts index 0389295732..fc42c3c265 100644 --- a/test/api.ts +++ b/test/api.ts @@ -45,7 +45,26 @@ describe('API', () => { }); }); - // TODO: APIエラーのテスト + test('error', async () => { + fetchMock.resetMocks(); + fetchMock.mockResponse(async (req) => { + return { + status: 500, + body: JSON.stringify({ + message: 'Internal error occurred. Please contact us if the error persists.', + code: 'INTERNAL_ERROR', + id: '5d37dbcb-891e-41ca-a3d6-e690c97775ac', + kind: 'server', + }) + }; + }); + + try { + await request('https://misskey.test', 'i', {}, 'TOKEN'); + } catch (e) { + expect(e.id).toEqual('5d37dbcb-891e-41ca-a3d6-e690c97775ac'); + } + }); // TODO: ネットワークエラーのテスト }); |