Skip to content

Commit 68fbc9b

Browse files
fix(pencil): fix format
1 parent d9d56dd commit 68fbc9b

File tree

8 files changed

+147
-143
lines changed

8 files changed

+147
-143
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"test": "lerna run test --parallel --stream",
1818
"build": "lerna run build --stream",
1919
"link:exec": "lerna run link:exec --stream",
20-
"lint:fix": "lerna run lint:fix --parallel --stream -- ./lib/**/*.js"
20+
"lint": "lerna run lint --parallel --stream -- ./lib/**/*.js ./__tests__/**/*.js",
21+
"lint:fix": "lerna run lint:fix --parallel --stream -- ./lib/**/*.js ./__tests__/**/*.js"
2122
},
2223
"dependencies": {
2324
"commander": "^9.0.0",
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,70 @@
1-
const fs = require('fs');
2-
const path = require('path');
3-
const assert = require('assert');
4-
const {execSync } = require("child_process");
5-
const StaticWado = require('../../lib');
6-
const deleteDir = require('../../lib/util/deleteDir');
1+
const fs = require("fs");
2+
const path = require("path");
3+
const assert = require("assert");
4+
const { execSync } = require("child_process");
5+
const StaticWado = require("../../lib");
6+
const deleteDir = require("../../lib/util/deleteDir");
77

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

1010
// 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`
13-
const junoSeriesDir = `${junoDir}/series/1.2.840.113619.2.5.1762583153.215519.978957063.121`
14-
const junoInstancesDir = `${junoSeriesDir}/instances/1.2.840.113619.2.5.1762583153.215519.978957063.122`
11+
const outputDir = "./tmp/dicomweb";
12+
const junoDir = `${outputDir}/studies/1.2.840.113619.2.5.1762583153.215519.978957063.78`;
13+
const junoSeriesDir = `${junoDir}/series/1.2.840.113619.2.5.1762583153.215519.978957063.121`;
14+
const junoInstancesDir = `${junoSeriesDir}/instances/1.2.840.113619.2.5.1762583153.215519.978957063.122`;
1515

16-
const junoStudiesFile = `${junoDir}/index.json.gz`
17-
const junoSeriesFile = `${junoDir}/series/index.json.gz`
18-
const junoInstancesFile = `${junoSeriesDir}/instances/index.json.gz`
19-
const junoFramesFile = `${junoInstancesDir}/frames/1.gz`
16+
const junoStudiesFile = `${junoDir}/index.json.gz`;
17+
const junoSeriesFile = `${junoDir}/series/index.json.gz`;
18+
const junoInstancesFile = `${junoSeriesDir}/instances/index.json.gz`;
19+
const junoFramesFile = `${junoInstancesDir}/frames/1.gz`;
2020

21+
describe("index", () => {
22+
const processes = {};
2123

22-
describe('index', () => {
24+
const importer = new StaticWado({
25+
isStudyData: true,
26+
isGroup: true,
27+
});
2328

24-
const processes = {};
29+
function assertExists(fileOrDir, exists = true) {
30+
assert.equal(fs.existsSync(fileOrDir), exists);
31+
}
2532

26-
const importer = new StaticWado({
27-
isStudyData: true,
28-
isGroup: true,
29-
});
33+
before(async () => {
34+
await deleteDir(outputDir, true);
35+
fs.mkdirSync(outputDir, { recursive: true });
3036

31-
function assertExists(fileOrDir, exists = true) {
32-
assert.equal(fs.existsSync(fileOrDir), exists);
33-
}
37+
assertExists(outputDir, true);
3438

35-
before(async() => {
36-
await deleteDir(outputDir, true);
37-
fs.mkdirSync(outputDir, {recursive: true})
39+
console.log("Created directory", outputDir, fs.existsSync(outputDir));
40+
});
3841

39-
assertExists(outputDir, true);
42+
const createJuno = () => {
43+
if (processes.createJuno) return;
44+
execSync(
45+
`node bin/mkdicomweb.js -o ${outputDir} ${TEST_DATA_PATH}/dcm/MisterMr/1.2.840.113619.2.5.1762583153.215519.978957063.122`,
46+
(error, stdout, stderr) => {
47+
if (error) {
48+
console.log(`error: ${error.message}`);
49+
return;
50+
}
51+
if (stderr) {
52+
console.log(`stderr: ${stderr}`);
53+
return;
54+
}
55+
console.log(`stdout: ${stdout}`);
56+
}
57+
);
58+
processes.createJuno = true;
59+
};
4060

41-
console.log('Created directory', outputDir, fs.existsSync(outputDir));
42-
})
61+
it("basic exists test", async () => {
62+
createJuno();
4363

44-
const createJuno = () => {
45-
if( processes.createJuno ) return;
46-
execSync(`node bin/mkdicomweb.js -o ${outputDir} ${TEST_DATA_PATH}/dcm/MisterMr/1.2.840.113619.2.5.1762583153.215519.978957063.122`, (error, stdout, stderr) => {
47-
if (error) {
48-
console.log(`error: ${error.message}`);
49-
return;
50-
}
51-
if (stderr) {
52-
console.log(`stderr: ${stderr}`);
53-
return;
54-
}
55-
console.log(`stdout: ${stdout}`);
56-
});
57-
processes.createJuno = true;
58-
}
59-
60-
it('basic exists test', async () => {
61-
createJuno();
62-
63-
assertExists(junoDir);
64-
assertExists(junoStudiesFile);
65-
assertExists(junoSeriesFile);
66-
assertExists(junoInstancesFile);
67-
assertExists(junoFramesFile);
68-
})
69-
})
64+
assertExists(junoDir);
65+
assertExists(junoStudiesFile);
66+
assertExists(junoSeriesFile);
67+
assertExists(junoInstancesFile);
68+
assertExists(junoFramesFile);
69+
});
70+
});
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
1-
const fs = require('fs')
2-
const path = require('path')
3-
const assert = require('assert');
4-
const asyncIteratorToBuffer = require('../../lib/operation/adapter/asyncIterableToBuffer')
1+
const fs = require("fs");
2+
const path = require("path");
3+
const assert = require("assert");
4+
const asyncIteratorToBuffer = require("../../lib/operation/adapter/asyncIterableToBuffer");
55

6-
const TEST_DATA_PATH = path.resolve(__dirname, '../../../../testdata');
7-
describe('asyncIterableToBuffer', () => {
8-
let dicomp10stream
6+
const TEST_DATA_PATH = path.resolve(__dirname, "../../../../testdata");
7+
describe("asyncIterableToBuffer", () => {
8+
let dicomp10stream;
99

10-
beforeEach(async() => {
11-
dicomp10stream = fs.createReadStream(`${TEST_DATA_PATH}/dcm/Juno/1.3.6.1.4.1.25403.345050719074.3824.20170125113606.8`);
12-
})
10+
beforeEach(async () => {
11+
dicomp10stream = fs.createReadStream(
12+
`${TEST_DATA_PATH}/dcm/Juno/1.3.6.1.4.1.25403.345050719074.3824.20170125113606.8`
13+
);
14+
});
1315

14-
it('copies child elements correctly', async () => {
15-
const buffer = await asyncIteratorToBuffer(dicomp10stream);
16-
const dest = new Uint8Array(132);
17-
// D character in DICM prefix
18-
assert.equal(buffer[128],68);
19-
buffer.copy(dest,0,0,132);
20-
// Should have copied
21-
assert.equal(dest[128],buffer[128]);
22-
})
16+
it("copies child elements correctly", async () => {
17+
const buffer = await asyncIteratorToBuffer(dicomp10stream);
18+
const dest = new Uint8Array(132);
19+
// D character in DICM prefix
20+
assert.equal(buffer[128], 68);
21+
buffer.copy(dest, 0, 0, 132);
22+
// Should have copied
23+
assert.equal(dest[128], buffer[128]);
24+
});
2325

24-
it('re-assembles buffers correctly', async () => {
25-
const buffer = await asyncIteratorToBuffer(dicomp10stream);
26-
const start = 3215+8;
27-
const len = 526728-start;
28-
29-
console.log('Slice buffer test')
30-
const subBuffer = buffer.slice(start,start+len);
31-
for(let i=0; i<len; i++) {
32-
const bufVal = buffer[i+start];
33-
const subVal = subBuffer[i];
34-
if( bufVal!=subVal ) {
35-
console.log(`At position ${i} relative to ${start} buffer is ${bufVal} but subVal is ${subVal}`)
36-
}
37-
assert.equal(buffer[i+start], subBuffer[i]);
38-
}
39-
})
26+
it("re-assembles buffers correctly", async () => {
27+
const buffer = await asyncIteratorToBuffer(dicomp10stream);
28+
const start = 3215 + 8;
29+
const len = 526728 - start;
4030

41-
})
31+
console.log("Slice buffer test");
32+
const subBuffer = buffer.slice(start, start + len);
33+
for (let i = 0; i < len; i++) {
34+
const bufVal = buffer[i + start];
35+
const subVal = subBuffer[i];
36+
if (bufVal != subVal) {
37+
console.log(
38+
`At position ${i} relative to ${start} buffer is ${bufVal} but subVal is ${subVal}`
39+
);
40+
}
41+
assert.equal(buffer[i + start], subBuffer[i]);
42+
}
43+
});
44+
});
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
1-
'use strict';
1+
"use strict";
22

3-
const fs = require('fs');
4-
const path = require('path');
5-
const assert = require('assert');
6-
const StaticWado = require('../../lib')
3+
const fs = require("fs");
4+
const path = require("path");
5+
const assert = require("assert");
6+
const StaticWado = require("../../lib");
77

8-
const TEST_DATA_PATH = path.resolve(__dirname, '../../../../testdata');
9-
describe('index', () => {
10-
let dicomp10stream
8+
const TEST_DATA_PATH = path.resolve(__dirname, "../../../../testdata");
9+
describe("index", () => {
10+
let dicomp10stream;
1111

12-
const importer = new StaticWado({
13-
isStudyData: true,
14-
isGroup: true,
15-
});
12+
const importer = new StaticWado({
13+
isStudyData: true,
14+
isGroup: true,
15+
});
1616

17-
beforeEach(async() => {
18-
//dicomp10stream = fs.createReadStream('../dagcom-test-data/dicom/WG04/compsamples_refanddir/IMAGES/REF/CT1_UNC')
19-
dicomp10stream = await fs.createReadStream(`${TEST_DATA_PATH}/dcm/MisterMr/1.2.840.113619.2.5.1762583153.215519.978957063.101`);
20-
//dicomp10stream = fs.createReadStream('../dagcom-test-data/dicom/encoding-variants/pixel-data/US_MF_RGB.implicit_little_endian.dcm')
21-
})
17+
beforeEach(async () => {
18+
//dicomp10stream = fs.createReadStream('../dagcom-test-data/dicom/WG04/compsamples_refanddir/IMAGES/REF/CT1_UNC')
19+
dicomp10stream = await fs.createReadStream(
20+
`${TEST_DATA_PATH}/dcm/MisterMr/1.2.840.113619.2.5.1762583153.215519.978957063.101`
21+
);
22+
//dicomp10stream = fs.createReadStream('../dagcom-test-data/dicom/encoding-variants/pixel-data/US_MF_RGB.implicit_little_endian.dcm')
23+
});
2224

23-
it('exports', () => {
24-
assert.notStrictEqual(importer, undefined)
25-
})
25+
it("exports", () => {
26+
assert.notStrictEqual(importer, undefined);
27+
});
2628

27-
// TODO - add integration tests
28-
})
29+
// TODO - add integration tests
30+
});
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
const fs = require('fs');
2-
3-
async function deleteDir (dir) {
4-
5-
try {
6-
7-
// equivalent to rm -rf
8-
await fs.promises.rm(dir,{ recursive: true, force: true } );
9-
10-
} catch(error) {
11-
console.log(`error: ${error.message}`);
12-
return;
13-
}
14-
15-
console.log('Delete done');
1+
const fs = require("fs");
2+
3+
async function deleteDir(dir) {
4+
try {
5+
// equivalent to rm -rf
6+
await fs.promises.rm(dir, { recursive: true, force: true });
7+
} catch (error) {
8+
console.log(`error: ${error.message}`);
9+
return;
10+
}
11+
12+
console.log("Delete done");
1613
}
1714

18-
module.exports = deleteDir;
15+
module.exports = deleteDir;
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict';
1+
"use strict";
22

3-
const staticWadoScp = require('..');
3+
const staticWadoScp = require("..");
44

5-
describe('@ohif/static-wado-scp', () => {
6-
it('needs tests');
5+
describe("@ohif/static-wado-scp", () => {
6+
it("needs tests");
77
});
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict';
1+
"use strict";
22

3-
const staticWadoUtil = require('..');
3+
const staticWadoUtil = require("..");
44

5-
describe('@ohif/static-wado-util', () => {
6-
it('needs tests');
5+
describe("@ohif/static-wado-util", () => {
6+
it("needs tests");
77
});
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict';
1+
"use strict";
22

3-
const staticWadoWebserver = require('..');
3+
const staticWadoWebserver = require("..");
44

5-
describe('@ohif/static-wado-webserver', () => {
6-
it('needs tests');
5+
describe("@ohif/static-wado-webserver", () => {
6+
it("needs tests");
77
});

0 commit comments

Comments
 (0)