summaryrefslogtreecommitdiff
path: root/tests/unit_node/testdata
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_node/testdata')
-rw-r--r--tests/unit_node/testdata/worker_module/cjs-file.cjs23
-rw-r--r--tests/unit_node/testdata/worker_module/index.js2
-rw-r--r--tests/unit_node/testdata/worker_module/nested/index.js3
-rw-r--r--tests/unit_node/testdata/worker_module/other_cjs_file.cjs5
-rw-r--r--tests/unit_node/testdata/worker_module/other_file.js7
-rw-r--r--tests/unit_node/testdata/worker_module/βάρβαροι.js9
6 files changed, 47 insertions, 2 deletions
diff --git a/tests/unit_node/testdata/worker_module/cjs-file.cjs b/tests/unit_node/testdata/worker_module/cjs-file.cjs
new file mode 100644
index 000000000..af2e21c35
--- /dev/null
+++ b/tests/unit_node/testdata/worker_module/cjs-file.cjs
@@ -0,0 +1,23 @@
+const { add } = require("./other_cjs_file.cjs");
+
+const missing_toplevel_async = async () => {
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve;
+ }, 500);
+ });
+};
+
+async function main() {
+ /// async code doesn't seem to work within this CJS wrapper :(
+ //const p = await missing_toplevel_async();
+
+ const sum = add(2, 3);
+ if (sum != 5) {
+ throw ("Bad calculator!");
+ }
+
+ postMessage("hallo");
+}
+
+main();
diff --git a/tests/unit_node/testdata/worker_module/index.js b/tests/unit_node/testdata/worker_module/index.js
index a3e976b65..cbb433986 100644
--- a/tests/unit_node/testdata/worker_module/index.js
+++ b/tests/unit_node/testdata/worker_module/index.js
@@ -1,3 +1,3 @@
import { myFunction } from "./other_file.js";
-myFunction().then(() => {});
+await myFunction();
diff --git a/tests/unit_node/testdata/worker_module/nested/index.js b/tests/unit_node/testdata/worker_module/nested/index.js
new file mode 100644
index 000000000..b77376a16
--- /dev/null
+++ b/tests/unit_node/testdata/worker_module/nested/index.js
@@ -0,0 +1,3 @@
+import { myFunction } from "../other_file.js";
+
+await myFunction();
diff --git a/tests/unit_node/testdata/worker_module/other_cjs_file.cjs b/tests/unit_node/testdata/worker_module/other_cjs_file.cjs
new file mode 100644
index 000000000..45ae337bf
--- /dev/null
+++ b/tests/unit_node/testdata/worker_module/other_cjs_file.cjs
@@ -0,0 +1,5 @@
+module.exports = {
+ add: (a, b) => {
+ return a + b;
+ },
+};
diff --git a/tests/unit_node/testdata/worker_module/other_file.js b/tests/unit_node/testdata/worker_module/other_file.js
index 41789dfe8..6bb9b6b83 100644
--- a/tests/unit_node/testdata/worker_module/other_file.js
+++ b/tests/unit_node/testdata/worker_module/other_file.js
@@ -1,3 +1,8 @@
export async function myFunction() {
- await new Promise((resolve) => setTimeout(resolve, 100));
+ await new Promise((resolve) =>
+ setTimeout(() => {
+ postMessage("hallo");
+ resolve;
+ }, 100)
+ );
}
diff --git a/tests/unit_node/testdata/worker_module/βάρβαροι.js b/tests/unit_node/testdata/worker_module/βάρβαροι.js
new file mode 100644
index 000000000..cee92889c
--- /dev/null
+++ b/tests/unit_node/testdata/worker_module/βάρβαροι.js
@@ -0,0 +1,9 @@
+export async function myFunction() {
+ await new Promise((resolve) =>
+ setTimeout(() => {
+ postMessage("hallo");
+ resolve;
+ }, 100)
+ );
+}
+await myFunction();