-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Using globalThis instead of window
* fix: Using globalThis instead of window. * Add test for worker thread importing deno_mongo. Co-authored-by: silence <silence_zhpf@aliyun.com> Co-authored-by: ERFANIUM <erfanshield@outlook.com>
- Loading branch information
1 parent
eda9e9c
commit a152fb5
Showing
4 changed files
with
38 additions
and
2 deletions.
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,29 @@ | ||
import { assert } from "../test.deps.ts"; | ||
|
||
export default function workerTests() { | ||
Deno.test({ | ||
name: "WORKER: Deno does not throw when deno_mongo is imported in worker", | ||
fn: async function () { | ||
let workerFinished: (p: void | PromiseLike<void>) => void; | ||
|
||
const p = new Promise<void>((resolve, _reject) => { | ||
workerFinished = resolve; | ||
}); | ||
|
||
const importWorker = new Worker( | ||
new URL("import_worker.ts", import.meta.url).href, | ||
{ type: "module" }, | ||
); | ||
|
||
importWorker.onmessage = (_e) => { | ||
workerFinished(); | ||
}; | ||
|
||
importWorker.postMessage("startWorker"); | ||
|
||
await p; | ||
|
||
assert(true); | ||
}, | ||
}); | ||
} |
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,6 @@ | ||
import {} from "../../mod.ts"; | ||
|
||
onmessage = (_e) => { | ||
self.postMessage("done"); | ||
self.close(); | ||
}; |
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