-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #53 Add integration tests for cancel, but it is skipped
- Loading branch information
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Mastodon from '@/mastodon' | ||
import Worker from 'jest-worker' | ||
|
||
jest.mock('axios', () => { | ||
const mockAxios = jest.requireActual('axios') | ||
mockAxios.get = (_path: string) => { | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
console.log('hoge') | ||
resolve({ | ||
data: 'hoge', | ||
status: 200, | ||
statusText: '200OK', | ||
headers: [], | ||
config: {} | ||
}) | ||
}, 5000) | ||
}) | ||
} | ||
return mockAxios | ||
}) | ||
|
||
const worker = async (client: Mastodon) => { | ||
const w: any = new Worker(require.resolve('./cancelWorker.ts')) | ||
await w.cancel(client) | ||
} | ||
|
||
// Could not use jest-worker under typescript. | ||
// I'm waiting for resolve this issue. | ||
// https://github.com/facebook/jest/issues/8872 | ||
describe.skip('cancel', () => { | ||
const client = new Mastodon('testToken', 'https://pleroma.io/api/v1') | ||
it('should be raised', async () => { | ||
const getPromise = client.get<{}>('/timelines/home') | ||
worker(client) | ||
await expect(getPromise).rejects.toThrow() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Mastodon from '@/mastodon' | ||
|
||
export function cancel(client: Mastodon) { | ||
return client.cancel() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters