@@ -306,4 +306,46 @@ describe('JSON', function() {
306306 assert ( issues . length === 1 && issues [ 0 ] . code == 55 )
307307 } )
308308 } )
309+
310+ var dataset_description_file = {
311+ name : 'dataset_description.json' ,
312+ relativePath : '/dataset_description.json' ,
313+ }
314+
315+ it ( 'dataset_description.json should validate with enum of DatasetType' , function ( ) {
316+ var jsonObj = {
317+ Name : 'Example Name' ,
318+ BIDSVersion : '1.4.0' ,
319+ Authors : [ 'example author' ] ,
320+ DatasetType : 'raw' ,
321+ }
322+ jsonDict [ dataset_description_file . relativePath ] = jsonObj
323+ validate . JSON ( dataset_description_file , jsonDict , function ( issues ) {
324+ assert ( issues . length === 0 )
325+ } )
326+ } )
327+
328+ it ( 'dataset_description.json should NOT validate with wrong enum of DatasetType' , function ( ) {
329+ var jsonObj = {
330+ Name : 'Example Name' ,
331+ BIDSVersion : '1.4.0' ,
332+ Authors : [ 'example author' ] ,
333+ DatasetType : 'badenum' ,
334+ }
335+ jsonDict [ dataset_description_file . relativePath ] = jsonObj
336+ validate . JSON ( dataset_description_file , jsonDict , function ( issues ) {
337+ assert ( issues . length === 1 && issues [ 0 ] . code == 55 )
338+ } )
339+ } )
340+
341+ it ( 'dataset_description.json should validate with only required fields, no recommended' , function ( ) {
342+ var jsonObj = {
343+ Name : 'Example Name' ,
344+ BIDSVersion : '1.4.0' ,
345+ }
346+ jsonDict [ dataset_description_file . relativePath ] = jsonObj
347+ validate . JSON ( dataset_description_file , jsonDict , function ( issues ) {
348+ assert ( issues . length === 0 )
349+ } )
350+ } )
309351} )
0 commit comments