@@ -2,10 +2,9 @@ const assert = require('assert')
22const headerFields = require ( '../validators/headerFields' )
33
44describe ( 'headerFields' , ( ) => {
5- it ( 'should throw an error if _magnitude1 or _magnitude2 files have too many dimensions.' , ( ) => {
6- // each of these headers has one too many dimensions on the 'dim' field.
7- // the first entry is the total count, and the following three entries are spatial.
5+ it ( 'should throw an error if _magnitude1 or _magnitude2 files do not have exactly dimensions.' , ( ) => {
86 const headers = [
7+ // each of these headers has one too many dimensions on the 'dim' field.
98 [
109 {
1110 name : 'sub-01_magnitude1.nii' ,
@@ -28,10 +27,37 @@ describe('headerFields', () => {
2827 xyzt_units : [ 5 , 1 , 1 , 1 , 1 ] ,
2928 } ,
3029 ] ,
30+ // each of these headers has one too few dimensions on the 'dim' field.
31+ [
32+ {
33+ name : 'sub-02_magnitude1.nii' ,
34+ relativePath : 'sub-02_magnitude1.nii' ,
35+ } ,
36+ {
37+ dim : [ 3 , 1 , 1 ] ,
38+ pixdim : [ 4 , 1 , 1 , 1 ] ,
39+ xyzt_units : [ 4 , 1 , 1 , 1 ] ,
40+ } ,
41+ ] ,
42+ [
43+ {
44+ name : 'sub-02_magnitude2.nii' ,
45+ relativePath : 'sub-02_magnitude2.nii' ,
46+ } ,
47+ {
48+ dim : [ 3 , 1 , 1 ] ,
49+ pixdim : [ 4 , 1 , 1 , 1 ] ,
50+ xyzt_units : [ 4 , 1 , 1 , 1 ] ,
51+ } ,
52+ ] ,
3153 ]
3254 const issues = headerFields ( headers )
3355 assert (
34- issues . length == 2 && issues [ 0 ] . code == '94' && issues [ 1 ] . code == '94' ,
56+ issues . length == 4 &&
57+ issues [ 0 ] . code == '94' &&
58+ issues [ 1 ] . code == '94' &&
59+ issues [ 2 ] . code == '94' &&
60+ issues [ 3 ] . code == '94' ,
3561 )
3662 } )
3763
@@ -54,7 +80,7 @@ describe('headerFields', () => {
5480 relativePath : 'sub-01_magnitude2.nii' ,
5581 } ,
5682 {
57- dim : [ 3 , 1 , 1 ] ,
83+ dim : [ 4 , 1 , 1 , 1 ] ,
5884 pixdim : [ 4 , 1 , 1 , 1 ] ,
5985 xyzt_units : [ 4 , 1 , 1 , 1 ] ,
6086 } ,
0 commit comments