mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-30 10:34:21 +01:00
Add fetchWorker for fetching off the main thread
This commit is contained in:
14
src/workers/fetch.test.ts
Normal file
14
src/workers/fetch.test.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { assert } from '@/deps-test.ts';
|
||||
|
||||
import { fetchWorker } from './fetch.ts';
|
||||
|
||||
Deno.test('fetchWorker', async () => {
|
||||
await sleep(2000);
|
||||
const response = await fetchWorker('https://example.com');
|
||||
const text = await response.text();
|
||||
assert(text.includes('Example Domain'));
|
||||
});
|
||||
|
||||
function sleep(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
Reference in New Issue
Block a user