@@ -581,4 +581,78 @@ describe("getSkipSegmentsByHash", () => {
581
581
} )
582
582
. catch ( err => done ( err ) ) ;
583
583
} ) ;
584
+
585
+ it ( "Should be able to get single segment with requiredSegments" , ( done ) => {
586
+ const requiredSegment1 = "fbf0af454059733c8822f6a4ac8ec568e0787f8c0a5ee915dd5b05e0d7a9a388" ;
587
+ client . get ( `${ endpoint } /17bf?requiredSegment=${ requiredSegment1 } ` )
588
+ . then ( res => {
589
+ assert . strictEqual ( res . status , 200 ) ;
590
+ const data = ( res . data as Array < any > ) . sort ( ( a , b ) => a . videoID . localeCompare ( b . videoID ) ) ;
591
+ assert . strictEqual ( data . length , 1 ) ;
592
+ const expected = [ {
593
+ segments : [ {
594
+ UUID : requiredSegment1
595
+ } ]
596
+ } ] ;
597
+ assert . ok ( partialDeepEquals ( data , expected ) ) ;
598
+ assert . strictEqual ( data [ 0 ] . segments . length , 1 ) ;
599
+ done ( ) ;
600
+ } )
601
+ . catch ( err => done ( err ) ) ;
602
+ } ) ;
603
+
604
+ it ( "Should return 400 if categories are is number" , ( done ) => {
605
+ client . get ( `${ endpoint } /17bf?categories=3` )
606
+ . then ( res => {
607
+ assert . strictEqual ( res . status , 400 ) ;
608
+ done ( ) ;
609
+ } )
610
+ . catch ( err => done ( err ) ) ;
611
+ } ) ;
612
+
613
+ it ( "Should return 400 if actionTypes is number" , ( done ) => {
614
+ client . get ( `${ endpoint } /17bf?actionTypes=3` )
615
+ . then ( res => {
616
+ assert . strictEqual ( res . status , 400 ) ;
617
+ done ( ) ;
618
+ } )
619
+ . catch ( err => done ( err ) ) ;
620
+ } ) ;
621
+
622
+ it ( "Should return 400 if actionTypes are invalid json" , ( done ) => {
623
+ client . get ( `${ endpoint } /17bf?actionTypes={test}` )
624
+ . then ( res => {
625
+ assert . strictEqual ( res . status , 400 ) ;
626
+ done ( ) ;
627
+ } )
628
+ . catch ( err => done ( err ) ) ;
629
+ } ) ;
630
+
631
+ it ( "Should return 400 if requiredSegments is number" , ( done ) => {
632
+ client . get ( `${ endpoint } /17bf?requiredSegments=3` )
633
+ . then ( res => {
634
+ assert . strictEqual ( res . status , 400 ) ;
635
+ done ( ) ;
636
+ } )
637
+ . catch ( err => done ( err ) ) ;
638
+ } ) ;
639
+
640
+
641
+ it ( "Should return 404 if requiredSegments is invalid json" , ( done ) => {
642
+ client . get ( `${ endpoint } /17bf?requiredSegments={test}` )
643
+ . then ( res => {
644
+ assert . strictEqual ( res . status , 400 ) ;
645
+ done ( ) ;
646
+ } )
647
+ . catch ( err => done ( err ) ) ;
648
+ } ) ;
649
+
650
+ it ( "Should return 400 if requiredSegments is not present" , ( done ) => {
651
+ client . get ( `${ endpoint } /17bf?requiredSegment=${ fullCategoryVidHash } ` )
652
+ . then ( res => {
653
+ assert . strictEqual ( res . status , 404 ) ;
654
+ done ( ) ;
655
+ } )
656
+ . catch ( err => done ( err ) ) ;
657
+ } ) ;
584
658
} ) ;
0 commit comments