| 
1 | 1 | import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';  | 
2 | 2 | import { CloudinaryVideoComponent } from '../lib/cloudinary-video.component';  | 
3 | 3 | import {CloudinaryImage, CloudinaryVideo} from '@cloudinary/url-gen';  | 
4 |  | -import { auto, vp9 } from '@cloudinary/url-gen/qualifiers/videoCodec';  | 
 | 4 | +import { auto, vp9, theora } from '@cloudinary/url-gen/qualifiers/videoCodec';  | 
5 | 5 | import { videoCodec } from '@cloudinary/url-gen/actions/transcode';  | 
6 | 6 | import {ElementRef} from "@angular/core";  | 
7 | 7 | 
 
  | 
@@ -90,6 +90,51 @@ describe('CloudinaryVideoComponent render', () => {  | 
90 | 90 |  .toEqual( 'video/webm; codecs=avc1.4D401E, mp4a.40.2');  | 
91 | 91 |  }));  | 
92 | 92 | 
 
  | 
 | 93 | + it('should render video with input sources when using useFetchFormat', fakeAsync(() => {  | 
 | 94 | + component.cldVid = cloudinaryVideo;  | 
 | 95 | + component.useFetchFormat = true;  | 
 | 96 | + component.sources = [  | 
 | 97 | + {  | 
 | 98 | + type: 'mp4',  | 
 | 99 | + codecs: ['vp8', 'vorbis'],  | 
 | 100 | + transcode: videoCodec(auto())  | 
 | 101 | + },  | 
 | 102 | + {  | 
 | 103 | + type: 'webm',  | 
 | 104 | + codecs: ['avc1.4D401E', 'mp4a.40.2'],  | 
 | 105 | + transcode: videoCodec(vp9())  | 
 | 106 | + },  | 
 | 107 | + {  | 
 | 108 | + type: 'ogv',  | 
 | 109 | + codecs: ['theora'],  | 
 | 110 | + transcode: videoCodec(theora())  | 
 | 111 | + }];  | 
 | 112 | + | 
 | 113 | + fixture.detectChanges();  | 
 | 114 | + tick(0);  | 
 | 115 | + const vidElement: HTMLVideoElement = fixture.nativeElement;  | 
 | 116 | + const video = vidElement.querySelector('video');  | 
 | 117 | + | 
 | 118 | + expect(video.childElementCount).toBe(3);  | 
 | 119 | + | 
 | 120 | + // First source  | 
 | 121 | + expect(video.children[0].attributes.getNamedItem('src').value)  | 
 | 122 | + .toEqual( 'https://res.cloudinary.com/demo/video/upload/vc_auto/f_mp4/sample');  | 
 | 123 | + expect(video.children[0].attributes.getNamedItem('type').value)  | 
 | 124 | + .toEqual( 'video/mp4; codecs=vp8, vorbis');  | 
 | 125 | + | 
 | 126 | + // Second source  | 
 | 127 | + expect(video.children[1].attributes.getNamedItem('src').value)  | 
 | 128 | + .toEqual( 'https://res.cloudinary.com/demo/video/upload/vc_vp9/f_webm/sample');  | 
 | 129 | + expect(video.children[1].attributes.getNamedItem('type').value)  | 
 | 130 | + .toEqual( 'video/webm; codecs=avc1.4D401E, mp4a.40.2');  | 
 | 131 | + | 
 | 132 | + // Third source  | 
 | 133 | + expect(video.children[2].attributes.getNamedItem('src').value)  | 
 | 134 | + .toEqual( 'https://res.cloudinary.com/demo/video/upload/vc_theora/f_ogv/sample');  | 
 | 135 | + expect(video.children[2].attributes.getNamedItem('type').value)  | 
 | 136 | + .toEqual( 'video/ogg; codecs=theora');  | 
 | 137 | + }));  | 
93 | 138 | 
 
  | 
94 | 139 |  it('should contain poster when "auto" is passed as cldPoster', fakeAsync(() => {  | 
95 | 140 |  component.cldVid = new CloudinaryVideo('sample', { cloudName: 'demo'}, { analytics: false });  | 
 | 
0 commit comments