@@ -206,7 +206,7 @@ describe('StructuralMetadataUtils class', () => {
206206 describe ( 'findWrapperSpans(), ' , ( ) => {
207207 let allSpans = [ ] ;
208208 beforeEach ( ( ) => {
209- allSpans = smu . getItemsOfType ( 'span' , testData ) ;
209+ allSpans = smu . getItemsOfType ( [ 'span' ] , testData ) ;
210210 } ) ;
211211 test ( 'for first timespan' , ( ) => {
212212 const obj = {
@@ -337,89 +337,79 @@ describe('StructuralMetadataUtils class', () => {
337337 } ) ;
338338
339339 describe ( 'getItemsOfType()' , ( ) => {
340- test ( 'type === div' , ( ) => {
341- const allDivs = [
342- {
343- type : 'div' ,
344- label : 'Title' ,
345- id : '123a-456b-789c-0d' ,
346- } ,
347- {
348- type : 'div' ,
349- label : 'First segment' ,
350- id : '123a-456b-789c-1d' ,
351- } ,
352- {
353- type : 'div' ,
354- label : 'Sub-Segment 1.1' ,
355- id : '123a-456b-789c-2d' ,
356- } ,
357- {
358- type : 'div' ,
359- label : 'Second segment' ,
360- id : '123a-456b-789c-5d' ,
361- } ,
362- {
363- type : 'div' ,
364- label : 'Sub-Segment 2.1' ,
365- id : '123a-456b-789c-6d' ,
366- } ,
367- {
368- type : 'div' ,
369- label : 'Sub-Segment 2.1.1' ,
370- id : '123a-456b-789c-7d' ,
371- } ,
372- ] ;
373- const value = smu . getItemsOfType ( 'div' , testData ) ;
340+ const allDivs = [
341+ { type : 'div' , label : 'Title' , id : '123a-456b-789c-0d' } ,
342+ { type : 'div' , label : 'First segment' , id : '123a-456b-789c-1d' } ,
343+ { type : 'div' , label : 'Sub-Segment 1.1' , id : '123a-456b-789c-2d' } ,
344+ { type : 'div' , label : 'Second segment' , id : '123a-456b-789c-5d' } ,
345+ { type : 'div' , label : 'Sub-Segment 2.1' , id : '123a-456b-789c-6d' } ,
346+ { type : 'div' , label : 'Sub-Segment 2.1.1' , id : '123a-456b-789c-7d' } ,
347+ ] ;
348+ const allSpans = [
349+ {
350+ type : 'span' , label : 'Segment 1.1' , id : '123a-456b-789c-3d' ,
351+ begin : '00:00:03.321' , end : '00:00:10.321' ,
352+ valid : true ,
353+ timeRange : { start : 3.321 , end : 10.321 }
354+ } ,
355+ {
356+ type : 'span' , label : 'Segment 1.2' , id : '123a-456b-789c-4d' ,
357+ begin : '00:00:11.231' , end : '00:08:00.001' ,
358+ valid : true ,
359+ timeRange : { start : 11.231 , end : 480.001 }
360+ } ,
361+ {
362+ type : 'span' , label : 'Segment 2.1' , id : '123a-456b-789c-8d' ,
363+ begin : '00:09:03.241' , end : '00:15:00.001' ,
364+ valid : true ,
365+ timeRange : { start : 543.241 , end : 900.001 }
366+ } ,
367+ ] ;
368+ test ( 'itemTypes = []' , ( ) => {
369+ const value = smu . getItemsOfType ( [ ] , testData ) ;
370+ expect ( value ) . toEqual ( [ ] ) ;
371+ } ) ;
372+
373+ test ( 'itemTypes = [\'root\']' , ( ) => {
374+ const value = smu . getItemsOfType ( [ 'root' ] , testData ) ;
375+ expect ( value ) . toHaveLength ( 1 ) ;
376+ expect ( value ) . toContainEqual ( {
377+ type : 'root' , label : 'Ima Title' , id : '123a-456b-789c-0d'
378+ } ) ;
379+ } ) ;
380+
381+ test ( 'itemTypes = [\'div\']' , ( ) => {
382+ const value = smu . getItemsOfType ( [ 'div' ] , testData ) ;
374383 expect ( value ) . toHaveLength ( allDivs . length ) ;
375384 expect ( value ) . toContainEqual ( {
376- type : 'div' ,
377- label : 'Sub-Segment 2.1' ,
378- id : '123a-456b-789c-6d' ,
385+ type : 'div' , label : 'Sub-Segment 2.1' , id : '123a-456b-789c-6d'
379386 } ) ;
380387 } ) ;
381- test ( 'type === span' , ( ) => {
382- const allSpans = [
383- {
384- type : 'span' ,
385- label : 'Segment 1.1' ,
386- id : '123a-456b-789c-3d' ,
387- begin : '00:00:03.321' ,
388- end : '00:00:10.321' ,
389- valid : true ,
390- timeRange : { start : 3.321 , end : 10.321 }
391- } ,
392- {
393- type : 'span' ,
394- label : 'Segment 1.2' ,
395- id : '123a-456b-789c-4d' ,
396- begin : '00:00:11.231' ,
397- end : '00:08:00.001' ,
398- valid : true ,
399- timeRange : { start : 11.231 , end : 480.001 }
400- } ,
401- {
402- type : 'span' ,
403- label : 'Segment 2.1' ,
404- id : '123a-456b-789c-8d' ,
405- begin : '00:09:03.241' ,
406- end : '00:15:00.001' ,
407- valid : true ,
408- timeRange : { start : 543.241 , end : 900.001 }
409- } ,
410- ] ;
411- const value = smu . getItemsOfType ( 'span' , testData ) ;
388+
389+ test ( 'itemTypes = [\'span\']' , ( ) => {
390+ const value = smu . getItemsOfType ( [ 'span' ] , testData ) ;
412391 expect ( value ) . toHaveLength ( allSpans . length ) ;
413392 expect ( value ) . toContainEqual ( {
414- type : 'span' ,
415- label : 'Segment 2.1' ,
416- id : '123a-456b-789c-8d' ,
417- begin : '00:09:03.241' ,
418- end : '00:15:00.001' ,
393+ type : 'span' , label : 'Segment 2.1' , id : '123a-456b-789c-8d' ,
394+ begin : '00:09:03.241' , end : '00:15:00.001' ,
419395 valid : true ,
420396 timeRange : { start : 543.241 , end : 900.001 }
421397 } ) ;
422398 } ) ;
399+
400+ test ( 'itemTypes = [\'div\', \'span\']' , ( ) => {
401+ const value = smu . getItemsOfType ( [ 'span' , 'div' ] , testData ) ;
402+ expect ( value ) . toHaveLength ( allSpans . length + allDivs . length ) ;
403+ expect ( value ) . toContainEqual ( {
404+ type : 'span' , label : 'Segment 2.1' , id : '123a-456b-789c-8d' ,
405+ begin : '00:09:03.241' , end : '00:15:00.001' ,
406+ valid : true ,
407+ timeRange : { start : 543.241 , end : 900.001 }
408+ } ) ;
409+ expect ( value ) . toContainEqual ( {
410+ type : 'div' , label : 'Sub-Segment 2.1' , id : '123a-456b-789c-6d'
411+ } ) ;
412+ } ) ;
423413 } ) ;
424414
425415 describe ( 'getParentItem()' , ( ) => {
@@ -1103,7 +1093,7 @@ describe('StructuralMetadataUtils class', () => {
11031093 smu . determineDropTargets ( dragSource , nestedTestSmData ) ;
11041094
11051095 // getItemsOfType() was called with parent scope for the nested timespan
1106- expect ( getItemsOfTypeSpy ) . toHaveBeenCalledWith ( 'span' , [ parentTimespan ] ) ;
1096+ expect ( getItemsOfTypeSpy ) . toHaveBeenCalledWith ( [ 'span' ] , [ parentTimespan ] ) ;
11071097 // Clear mock
11081098 getItemsOfTypeSpy . mockRestore ( ) ;
11091099 } ) ;
0 commit comments