Skip to content

Commit 0cac180

Browse files
committed
chore: Add specific NodeJS worker test
Signed-off-by: Gordon Smith <[email protected]>
1 parent f02277f commit 0cac180

File tree

14 files changed

+90
-39
lines changed

14 files changed

+90
-39
lines changed

cpp/base91/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ TARGET_LINK_LIBRARIES(base91lib
3737
)
3838

3939
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/base91lib.wasm DESTINATION dist COMPONENT runtime)
40+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/base91lib.wasm DESTINATION dist-test COMPONENT runtime)
4041

4142
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
4243
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/base91lib.wasm.map DESTINATION dist COMPONENT runtime)

cpp/expat/expatlib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ TARGET_LINK_LIBRARIES(expatlib
3737
)
3838

3939
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/expatlib.wasm DESTINATION dist COMPONENT runtime)
40+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/expatlib.wasm DESTINATION dist-test COMPONENT runtime)
4041

4142
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
4243
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/expatlib.wasm.map DESTINATION dist COMPONENT runtime)

cpp/graphviz/graphvizlib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ TARGET_LINK_LIBRARIES(graphvizlib PRIVATE
9090
# )
9191

9292
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/graphvizlib.wasm DESTINATION dist COMPONENT runtime)
93+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/graphvizlib.wasm DESTINATION dist-test COMPONENT runtime)
9394

9495
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
9596
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/graphvizlib.wasm.map DESTINATION dist COMPONENT runtime)

cpp/zstd/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ TARGET_LINK_LIBRARIES(zstdlib
3737
)
3838

3939
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdlib.wasm DESTINATION dist COMPONENT runtime)
40+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdlib.wasm DESTINATION dist-test COMPONENT runtime)
4041

4142
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
4243
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdlib.wasm.map DESTINATION dist COMPONENT runtime)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,4 @@
152152
"url": "https://github.com/hpcc-systems/hpcc-js-wasm/issues"
153153
},
154154
"homepage": "https://github.com/hpcc-systems/hpcc-js-wasm#readme"
155-
}
155+
}

rollup.config.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const nodeTpl = (input, cjsOutput, esOutput) => ({
5050
include: ["lib-es6/__tests__/*.js"],
5151
delimiters: ['', ''],
5252
values: {
53-
"../index": "../index-node"
53+
"\"../index\"": "\"../index-node\""
5454
}
5555
}),
5656
nodeResolve({
@@ -99,8 +99,9 @@ export default [
9999
browserTpl("lib-es6/extract", "dist/extract", "dist/extract.es6"),
100100

101101
browserTpl("lib-es6/__tests__/index", "dist-test/index", "dist-test/index.es6"),
102-
nodeTpl("lib-es6/__tests__/index", "dist-test/index.node", "dist-test/index.node.es6"),
103-
browserTpl("lib-es6/__tests__/worker", "dist-test/worker", "dist-test/worker.es6"),
102+
nodeTpl("lib-es6/__tests__/index-node", "dist-test/index.node", "dist-test/index.node.es6"),
103+
browserTpl("lib-es6/__tests__/worker-browser", "dist-test/worker", "dist-test/worker.es6"),
104+
nodeTpl("lib-es6/__tests__/worker-node", "dist-test/worker.node", "dist-test/worker.node.es6"),
104105

105106
binTpl("lib-es6/__bin__/dot-wasm", "bin/dot-wasm.mjs"),
106107
binTpl("lib-es6/__bin__/sfx-wasm", "bin/sfx-wasm.mjs"),

src/__tests__/base91.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,4 @@ describe("base91", function () {
3434
const data2 = zstd.decompress(compressed_data2);
3535
expect(data).to.deep.equal(data2);
3636
});
37-
38-
if (globalThis.window?.Worker) {
39-
it("worker", async function () {
40-
const data = new Uint8Array(Array.from({ length: 1000 }, (_, i) => i % 256));
41-
42-
const value = await new Promise(resolve => {
43-
const myWorker = new Worker("dist-test/worker.js");
44-
myWorker.postMessage(data);
45-
myWorker.onmessage = function (e) {
46-
resolve(e.data);
47-
};
48-
});
49-
expect(value).to.deep.equal(data);
50-
});
51-
52-
it("worker-es6", async function () {
53-
const data = new Uint8Array(Array.from({ length: 1000 }, (_, i) => i % 256));
54-
55-
const value = await new Promise(resolve => {
56-
const myWorker = new Worker("dist-test/worker.es6.js");
57-
myWorker.postMessage(data);
58-
myWorker.onmessage = function (e) {
59-
resolve(e.data);
60-
};
61-
});
62-
expect(value).to.deep.equal(data);
63-
});
64-
}
6537
});

src/__tests__/browser-tests.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { expect } from "chai";
2+
3+
describe("worker-browser", function () {
4+
it("worker-umd", async function () {
5+
const data = new Uint8Array(Array.from({ length: 1000 }, (_, i) => i % 256));
6+
7+
const value = await new Promise(resolve => {
8+
const myWorker = new Worker("dist-test/worker.js");
9+
myWorker.postMessage(data);
10+
myWorker.onmessage = function (e) {
11+
resolve(e.data);
12+
};
13+
});
14+
expect(value).to.deep.equal(data);
15+
});
16+
17+
it("worker-esm", async function () {
18+
const data = new Uint8Array(Array.from({ length: 1000 }, (_, i) => i % 256));
19+
20+
const value = await new Promise(resolve => {
21+
const myWorker = new Worker("dist-test/worker.es6.js");
22+
myWorker.postMessage(data);
23+
myWorker.onmessage = function (e) {
24+
resolve(e.data);
25+
};
26+
});
27+
expect(value).to.deep.equal(data);
28+
});
29+
});

src/__tests__/index-common.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { wasmFolder } from "../index";
2+
wasmFolder("dist");
3+
4+
export * from "./base91";
5+
export * from "./expat";
6+
export * from "./graphviz";
7+
export * from "./zstd";

src/__tests__/index-node.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./index-common";
2+
export * from "./node-tests";

0 commit comments

Comments
 (0)