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" ) ;
7
7
8
- const TEST_DATA_PATH = path . resolve ( __dirname , ' ../../../../testdata' ) ;
8
+ const TEST_DATA_PATH = path . resolve ( __dirname , " ../../../../testdata" ) ;
9
9
10
10
// 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` ;
15
15
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` ;
20
20
21
+ describe ( "index" , ( ) => {
22
+ const processes = { } ;
21
23
22
- describe ( 'index' , ( ) => {
24
+ const importer = new StaticWado ( {
25
+ isStudyData : true ,
26
+ isGroup : true ,
27
+ } ) ;
23
28
24
- const processes = { } ;
29
+ function assertExists ( fileOrDir , exists = true ) {
30
+ assert . equal ( fs . existsSync ( fileOrDir ) , exists ) ;
31
+ }
25
32
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 } ) ;
30
36
31
- function assertExists ( fileOrDir , exists = true ) {
32
- assert . equal ( fs . existsSync ( fileOrDir ) , exists ) ;
33
- }
37
+ assertExists ( outputDir , true ) ;
34
38
35
- before ( async ( ) => {
36
- await deleteDir ( outputDir , true ) ;
37
- fs . mkdirSync ( outputDir , { recursive : true } )
39
+ console . log ( "Created directory" , outputDir , fs . existsSync ( outputDir ) ) ;
40
+ } ) ;
38
41
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
+ } ;
40
60
41
- console . log ( 'Created directory' , outputDir , fs . existsSync ( outputDir ) ) ;
42
- } )
61
+ it ( "basic exists test" , async ( ) => {
62
+ createJuno ( ) ;
43
63
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
+ } ) ;
0 commit comments