@@ -73,17 +73,30 @@ describe('CloudinaryVideo', () => {
7373
7474 describe ( 'videos with nested transformations' , ( ) => {
7575 @Component ( {
76- template : `<cl-video id="video1" public-id="sample_video">
77- <cl-transformation width="300" crop="scale" overlay="text:roboto_35_bold:SDK"></cl-transformation>
78- <cl-transformation effect="art:hokusai"></cl-transformation>
79- <cl-transformation fetch_format="auto"></cl-transformation>
80- </cl-video>`
76+ template : `
77+ <cl-video id="video1" public-id="sample_video">
78+ <cl-transformation width="300" crop="scale" keyframe_interval="10" overlay="text:roboto_35_bold:SDK"></cl-transformation>
79+ <cl-transformation effect="art:hokusai"></cl-transformation>
80+ <cl-transformation fetch_format="auto"></cl-transformation>
81+ </cl-video>
82+ <cl-video id="video2" public-id="sample_video">
83+ <cl-transformation width="300" crop="scale" keyframe-interval="0.05" overlay="text:roboto_35_bold:SDK"></cl-transformation>
84+ <cl-transformation effect="art:hokusai"></cl-transformation>
85+ <cl-transformation fetch_format="auto"></cl-transformation>
86+ </cl-video>
87+ <cl-video id="video3" public-id="sample_video">
88+ <cl-transformation keyframe_interval="3.45"></cl-transformation>
89+ </cl-video>
90+ <cl-video id="video4" public-id="sample_video">
91+ <cl-transformation keyframe_interval="300"></cl-transformation>
92+ </cl-video>
93+ `
8194 } )
8295 class TestComponent {
8396 }
8497
8598 let fixture : ComponentFixture < TestComponent > ;
86- let des : DebugElement ; // the elements w/ the directive
99+ let des : DebugElement [ ] ; // the elements w/ the directive
87100
88101 beforeEach ( ( ) => {
89102 fixture = TestBed . configureTestingModule ( {
@@ -94,25 +107,33 @@ describe('CloudinaryVideo', () => {
94107 fixture . detectChanges ( ) ; // initial binding
95108
96109 // all elements with an attached CloudinaryVideo
97- des = fixture . debugElement . query ( By . directive ( CloudinaryVideo ) ) ;
110+ des = fixture . debugElement . queryAll ( By . directive ( CloudinaryVideo ) ) ;
98111 } ) ;
99112
100113 it ( 'creates a <video> element which encodes the directive attributes to the URL' , ( ) => {
101- const video = des . children [ 0 ] . nativeElement as HTMLVideoElement ;
102- // Created <video> element should have 3 child <source> elements for mp4, webm, ogg
103- expect ( video . childElementCount ) . toBe ( 3 ) ;
114+ des . forEach ( ( element , index ) => {
115+ const matchers = [
116+ / c _ s c a l e , k i _ 1 0 , l _ t e x t : r o b o t o _ 3 5 _ b o l d : S D K , w _ 3 0 0 \/ e _ a r t : h o k u s a i \/ f _ a u t o \/ s a m p l e _ v i d e o / ,
117+ / c _ s c a l e , k i _ 0 \. 0 5 , l _ t e x t : r o b o t o _ 3 5 _ b o l d : S D K , w _ 3 0 0 \/ e _ a r t : h o k u s a i \/ f _ a u t o \/ s a m p l e _ v i d e o / ,
118+ / k i _ 3 \. 4 5 \/ s a m p l e _ v i d e o / ,
119+ / k i _ 3 0 0 \/ s a m p l e _ v i d e o / ,
120+
121+ ] ;
122+ const video = element . children [ 0 ] . nativeElement as HTMLVideoElement ;
123+ // Created <video> element should have 3 child <source> elements for mp4, webm, ogg
124+ expect ( video . childElementCount ) . toBe ( 3 ) ;
104125
105- for ( let i = 0 ; i < 3 ; i ++ ) {
106- expect ( video . children [ i ] . attributes . getNamedItem ( 'src' ) ) . toBeDefined ( ) ;
107- expect ( video . children [ i ] . attributes . getNamedItem ( 'src' ) . value ) . toEqual (
108- jasmine . stringMatching
109- ( / c _ s c a l e , l _ t e x t : r o b o t o _ 3 5 _ b o l d : S D K , w _ 3 0 0 \/ e _ a r t : h o k u s a i \/ f _ a u t o \/ s a m p l e _ v i d e o / ) ) ;
110- expect ( video . children [ i ] . attributes . getNamedItem ( 'src' ) . value ) . toEqual (
111- jasmine . stringMatching ( / v i d e o \/ u p l o a d / ) ) ;
112- }
126+ for ( let i = 0 ; i < 3 ; i ++ ) {
127+ expect ( video . children [ i ] . attributes . getNamedItem ( 'src' ) ) . toBeDefined ( ) ;
128+ expect ( video . children [ i ] . attributes . getNamedItem ( 'src' ) . value ) . toEqual (
129+ jasmine . stringMatching ( matchers [ index ] ) ) ;
130+ expect ( video . children [ i ] . attributes . getNamedItem ( 'src' ) . value ) . toEqual (
131+ jasmine . stringMatching ( / v i d e o \/ u p l o a d / ) ) ;
132+ }
133+ } ) ;
113134
114135 // verify interaction with underlying cloudinary-core lib
115- expect ( localCloudinary . videoTag ) . toHaveBeenCalledTimes ( 1 ) ;
136+ expect ( localCloudinary . videoTag ) . toHaveBeenCalledTimes ( 4 ) ;
116137 } ) ;
117138 } ) ;
118139
0 commit comments