wip
This commit is contained in:
parent
eacb5fea9f
commit
6dc01cd109
4 changed files with 9918 additions and 802 deletions
29
test/api.ts
Normal file
29
test/api.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import fetchMock from 'fetch-mock-jest';
|
||||
import { request } from '../src/api';
|
||||
|
||||
describe('API', () => {
|
||||
test('success', async () => {
|
||||
fetchMock
|
||||
.post('https://misskey.test/api/i', (url, options) => {
|
||||
if (typeof options.body.i === 'string') {
|
||||
return {
|
||||
body: {
|
||||
id: 'foo'
|
||||
}
|
||||
};
|
||||
}
|
||||
return 400;
|
||||
});
|
||||
|
||||
const res = await request('https://misskey.test', 'i', {}, 'TOKEN');
|
||||
|
||||
expect(res).toEqual({
|
||||
id: 'foo'
|
||||
});
|
||||
|
||||
expect(fetchMock).toHaveLastFetched({
|
||||
url: 'https://misskey.test/api/i',
|
||||
body: { i: 'TOKEN' }
|
||||
}, 'post');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue