Skip to content

Commit 9194f3f

Browse files
fix(pencil): adding must package and minor test changes
1 parent 68fbc9b commit 9194f3f

File tree

12 files changed

+123
-919
lines changed

12 files changed

+123
-919
lines changed

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
},
99
"devDependencies": {
1010
"jest": "^27.5.1",
11-
"lerna": "^4.0.0"
11+
"lerna": "^4.0.0",
12+
"must": "^0.13.4",
13+
"prettier": "^2.5.1"
14+
},
15+
"dependencies": {
16+
"commander": "^9.0.0",
17+
"husky": "^7.0.4"
1218
},
1319
"workspaces": [
1420
"packages/*"
@@ -17,13 +23,7 @@
1723
"test": "lerna run test --parallel --stream",
1824
"build": "lerna run build --stream",
1925
"link:exec": "lerna run link:exec --stream",
20-
"lint": "lerna run lint --parallel --stream -- ./lib/**/*.js ./__tests__/**/*.js",
21-
"lint:fix": "lerna run lint:fix --parallel --stream -- ./lib/**/*.js ./__tests__/**/*.js"
22-
},
23-
"dependencies": {
24-
"commander": "^9.0.0",
25-
"husky": "^7.0.4",
26-
"jest-runner-mocha": "^0.6.0",
27-
"prettier": "^2.5.1"
26+
"lint": "lerna run lint --parallel --stream -- ./lib/**/*.js ./tests/**/*.js",
27+
"lint:fix": "lerna run lint:fix --parallel --stream -- ./lib/**/*.js ./tests/**/*.js"
2828
}
2929
}
+13-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
const path = require("path");
2+
3+
const packageRoot = path.resolve(__dirname, './');
4+
const parentPackageRoot = path.resolve(__dirname, "../../");
5+
16
module.exports = {
27
verbose: true,
3-
runner: "jest-runner-mocha",
8+
globals: {
9+
TEST_DATA_PATH: path.join(parentPackageRoot, "/testdata"),
10+
OUTPUT_TEMP_PATH: path.join(packageRoot, "/tmp/dicomweb"),
11+
},
12+
setupFilesAfterEnv: [path.join(packageRoot, '/jest.setup.js')],
13+
globalTeardown: path.join(packageRoot, '/jest.global.teardown.js'),
414
// just does not yet support subpath export from node
515
moduleNameMapper: {
6-
"(.*)-(charls|openjpeg)\/wasmjs": "<rootDir>/node_modules/$1-$2/dist/$2wasm.js",
7-
"(.*)-(libjpeg)-(turbo)-(8bit)\/wasmjs": "<rootDir>/node_modules/$1-$2-$3-$4/dist/$2$3wasm.js",
16+
"(.*)-(charls|openjpeg)\/wasmjs": "$1-$2/dist/$2wasm.js",
17+
"(.*)-(libjpeg)-(turbo)-(8bit)\/wasmjs": "$1-$2-$3-$4/dist/$2$3wasm.js",
818
},
919
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
const path = require('path');
3+
const deleteDir = require("./lib/util/deleteDir");
4+
5+
const packageRoot = path.resolve(__dirname, './');
6+
7+
module.exports = async (globals) => {
8+
console.log('removing temp folder', globals);
9+
await deleteDir(path.join(packageRoot, "/tmp"), true);
10+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
// turn must package global
3+
require("must/register");

packages/static-wado-creator/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"mkdicomwebstudy": "bin/mkdicomwebstudy.js"
4646
},
4747
"scripts": {
48-
"test": "jest --config ./jest.config.js __test__/**/*.js",
48+
"test": "jest --config ./jest.config.js tests/**/*.js",
4949
"build": "echo \"No build yet\" && exit 0",
5050
"link:exec": "npm link",
5151
"lint": "npx prettier",

packages/static-wado-creator/__tests__/e2e/index.js renamed to packages/static-wado-creator/tests/e2e/index.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
const fs = require("fs");
2-
const path = require("path");
3-
const assert = require("assert");
42
const { execSync } = require("child_process");
53
const StaticWado = require("../../lib");
64
const deleteDir = require("../../lib/util/deleteDir");
75

8-
const TEST_DATA_PATH = path.resolve(__dirname, "../../../../testdata");
96

107
// same level at package folder
11-
const outputDir = "./tmp/dicomweb";
12-
const junoDir = `${outputDir}/studies/1.2.840.113619.2.5.1762583153.215519.978957063.78`;
8+
const junoDir = `${OUTPUT_TEMP_PATH}/studies/1.2.840.113619.2.5.1762583153.215519.978957063.78`;
139
const junoSeriesDir = `${junoDir}/series/1.2.840.113619.2.5.1762583153.215519.978957063.121`;
1410
const junoInstancesDir = `${junoSeriesDir}/instances/1.2.840.113619.2.5.1762583153.215519.978957063.122`;
1511

@@ -27,22 +23,22 @@ describe("index", () => {
2723
});
2824

2925
function assertExists(fileOrDir, exists = true) {
30-
assert.equal(fs.existsSync(fileOrDir), exists);
26+
fs.existsSync(fileOrDir).must.be.eql(exists);
3127
}
3228

33-
before(async () => {
34-
await deleteDir(outputDir, true);
35-
fs.mkdirSync(outputDir, { recursive: true });
29+
beforeEach(async () => {
30+
await deleteDir(OUTPUT_TEMP_PATH, true);
31+
fs.mkdirSync(OUTPUT_TEMP_PATH, { recursive: true });
3632

37-
assertExists(outputDir, true);
33+
assertExists(OUTPUT_TEMP_PATH, true);
3834

39-
console.log("Created directory", outputDir, fs.existsSync(outputDir));
35+
console.log("Created directory", OUTPUT_TEMP_PATH, fs.existsSync(OUTPUT_TEMP_PATH));
4036
});
4137

4238
const createJuno = () => {
4339
if (processes.createJuno) return;
4440
execSync(
45-
`node bin/mkdicomweb.js -o ${outputDir} ${TEST_DATA_PATH}/dcm/MisterMr/1.2.840.113619.2.5.1762583153.215519.978957063.122`,
41+
`node bin/mkdicomweb.js -o ${OUTPUT_TEMP_PATH} ${TEST_DATA_PATH}/dcm/MisterMr/1.2.840.113619.2.5.1762583153.215519.978957063.122`,
4642
(error, stdout, stderr) => {
4743
if (error) {
4844
console.log(`error: ${error.message}`);

packages/static-wado-creator/__tests__/unit/asyncIterable.js renamed to packages/static-wado-creator/tests/unit/asyncIterable.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
const fs = require("fs");
2-
const path = require("path");
3-
const assert = require("assert");
42
const asyncIteratorToBuffer = require("../../lib/operation/adapter/asyncIterableToBuffer");
53

6-
const TEST_DATA_PATH = path.resolve(__dirname, "../../../../testdata");
74
describe("asyncIterableToBuffer", () => {
85
let dicomp10stream;
96

107
beforeEach(async () => {
8+
119
dicomp10stream = fs.createReadStream(
1210
`${TEST_DATA_PATH}/dcm/Juno/1.3.6.1.4.1.25403.345050719074.3824.20170125113606.8`
1311
);
@@ -17,10 +15,11 @@ describe("asyncIterableToBuffer", () => {
1715
const buffer = await asyncIteratorToBuffer(dicomp10stream);
1816
const dest = new Uint8Array(132);
1917
// D character in DICM prefix
20-
assert.equal(buffer[128], 68);
18+
(buffer[128]).must.be.eql(68);
2119
buffer.copy(dest, 0, 0, 132);
2220
// Should have copied
23-
assert.equal(dest[128], buffer[128]);
21+
22+
(dest[128]).must.be.eql(buffer[128]);
2423
});
2524

2625
it("re-assembles buffers correctly", async () => {
@@ -38,7 +37,7 @@ describe("asyncIterableToBuffer", () => {
3837
`At position ${i} relative to ${start} buffer is ${bufVal} but subVal is ${subVal}`
3938
);
4039
}
41-
assert.equal(buffer[i + start], subBuffer[i]);
40+
(buffer[i + start]).must.be.eql(subBuffer[i]);
4241
}
4342
});
4443
});

packages/static-wado-creator/__tests__/unit/index.js renamed to packages/static-wado-creator/tests/unit/index.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
"use strict";
22

33
const fs = require("fs");
4-
const path = require("path");
5-
const assert = require("assert");
64
const StaticWado = require("../../lib");
75

8-
const TEST_DATA_PATH = path.resolve(__dirname, "../../../../testdata");
96
describe("index", () => {
107
let dicomp10stream;
118

@@ -23,7 +20,7 @@ describe("index", () => {
2320
});
2421

2522
it("exports", () => {
26-
assert.notStrictEqual(importer, undefined);
23+
importer.must.not.be.undefined();
2724
});
2825

2926
// TODO - add integration tests

0 commit comments

Comments
 (0)