Skip to content

Commit 2ce8c41

Browse files
YomesInctocker
authored andcommitted
Add a test of keyframe_interval (ki) parameter
1 parent bc440d7 commit 2ce8c41

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

src/cloudinary-video.component.spec.ts

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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_scale,ki_10,l_text:roboto_35_bold:SDK,w_300\/e_art:hokusai\/f_auto\/sample_video/,
117+
/c_scale,ki_0\.05,l_text:roboto_35_bold:SDK,w_300\/e_art:hokusai\/f_auto\/sample_video/,
118+
/ki_3\.45\/sample_video/,
119+
/ki_300\/sample_video/,
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_scale,l_text:roboto_35_bold:SDK,w_300\/e_art:hokusai\/f_auto\/sample_video/));
110-
expect(video.children[i].attributes.getNamedItem('src').value).toEqual(
111-
jasmine.stringMatching(/video\/upload/));
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(/video\/upload/));
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

Comments
 (0)