Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkassimo committed Aug 4, 2019
1 parent 715aab4 commit d4f063e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/039_worker_deno_ns.test
@@ -0,0 +1,2 @@
args: run --reload tests/039_worker_deno_ns.ts
output: tests/039_worker_deno_ns.ts.out
25 changes: 25 additions & 0 deletions tests/039_worker_deno_ns.ts
@@ -0,0 +1,25 @@
const w1 = new Worker("./tests/039_worker_deno_ns/has_ns.ts");
const w2 = new Worker("./tests/039_worker_deno_ns/no_ns.ts", {
deno: { noDenoNamespace: true }
});
let w1MsgCount = 0;
let w2MsgCount = 0;
w1.onmessage = (msg): void => {
console.log(msg.data);
w1MsgCount++;
if (w1MsgCount === 1) {
w1.postMessage("CONTINUE");
} else {
w2.postMessage("START");
}
};
w2.onmessage = (msg): void => {
console.log(msg.data);
w2MsgCount++;
if (w2MsgCount === 1) {
w2.postMessage("CONTINUE");
} else {
Deno.exit(0);
}
};
w1.postMessage("START");
4 changes: 4 additions & 0 deletions tests/039_worker_deno_ns.ts.out
@@ -0,0 +1,4 @@
has_ns.ts: is window.Deno available: true
[SPAWNED BY has_ns.ts] maybe_ns.ts: is window.Deno available: true
no_ns.ts: is window.Deno available: false
[SPAWNED BY no_ns.ts] maybe_ns.ts: is window.Deno available: false
10 changes: 10 additions & 0 deletions tests/039_worker_deno_ns/has_ns.ts
@@ -0,0 +1,10 @@
onmessage = (msg): void => {
if (msg.data === "START") {
postMessage("has_ns.ts: is window.Deno available: " + !!window.Deno);
} else {
const worker = new Worker("./tests/039_worker_deno_ns/maybe_ns.ts");
worker.onmessage = (msg): void => {
postMessage("[SPAWNED BY has_ns.ts] " + msg.data);
};
}
};
1 change: 1 addition & 0 deletions tests/039_worker_deno_ns/maybe_ns.ts
@@ -0,0 +1 @@
postMessage("maybe_ns.ts: is window.Deno available: " + !!window.Deno);
10 changes: 10 additions & 0 deletions tests/039_worker_deno_ns/no_ns.ts
@@ -0,0 +1,10 @@
onmessage = (msg): void => {
if (msg.data === "START") {
postMessage("no_ns.ts: is window.Deno available: " + !!window.Deno);
} else {
const worker = new Worker("./tests/039_worker_deno_ns/maybe_ns.ts");
worker.onmessage = (msg): void => {
postMessage("[SPAWNED BY no_ns.ts] " + msg.data);
};
}
};

0 comments on commit d4f063e

Please sign in to comment.