@@ -81,6 +81,53 @@ describe('CloudinaryImage', () => {
8181 } ) ;
8282 } ) ;
8383
84+ describe ( 'images with overlay/underlay' , ( ) => {
85+ @Component ( {
86+ template : `
87+ <cl-image responsive id="image1" public-id="responsive_sample.jpg">
88+ <cl-transformation overlay="fetch:http://cloudinary.com/images/old_logo.png"></cl-transformation>
89+ <cl-transformation underlay="fetch:http://cloudinary.com/images/old_logo.png"></cl-transformation>
90+ </cl-image>
91+ <cl-image responsive id="image2" public-id="responsive_sample.jpg">
92+ <cl-transformation overlay="fetch:https://upload.wikimedia.org/wikipedia/commons/2/2b/고창갯벌.jpg"></cl-transformation>
93+ <cl-transformation underlay="fetch:https://upload.wikimedia.org/wikipedia/commons/2/2b/고창갯벌.jpg"></cl-transformation>
94+ </cl-image>
95+ `
96+ } )
97+ class TestComponent { }
98+ let fixture : ComponentFixture < TestComponent > ;
99+ let des : DebugElement [ ] ;
100+
101+ beforeEach ( ( ) => {
102+ fixture = TestBed . configureTestingModule ( {
103+ declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent ] ,
104+ providers : [ { provide : Cloudinary , useValue : localCloudinary } ]
105+ } ) . createComponent ( TestComponent ) ;
106+ fixture . detectChanges ( ) ; // initial binding
107+ // all elements with an attached CloudinaryImage
108+ des = fixture . debugElement . queryAll ( By . directive ( CloudinaryImage ) ) ;
109+ } ) ;
110+
111+ it ( 'should serialize a fetch URL' , ( ) => {
112+ const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
113+ expect ( img . src ) . toEqual ( jasmine . stringMatching
114+ ( / l _ f e t c h : a H R 0 c D o v L 2 N s b 3 V k a W 5 h c n k u Y 2 9 t L 2 l t Y W d l c y 9 v b G R f b G 9 n b y 5 w b m c = \/ u _ f e t c h : a H R 0 c D o v L 2 N s b 3 V k a W 5 h c n k u Y 2 9 t L 2 l t Y W d l c y 9 v b G R f b G 9 n b y 5 w b m c = \/ r e s p o n s i v e _ s a m p l e .j p g / ) ) ;
115+ expect ( img . attributes . getNamedItem ( 'data-src' ) . value ) . toEqual ( jasmine . stringMatching (
116+ / l _ f e t c h : a H R 0 c D o v L 2 N s b 3 V k a W 5 h c n k u Y 2 9 t L 2 l t Y W d l c y 9 v b G R f b G 9 n b y 5 w b m c = \/ u _ f e t c h : a H R 0 c D o v L 2 N s b 3 V k a W 5 h c n k u Y 2 9 t L 2 l t Y W d l c y 9 v b G R f b G 9 n b y 5 w b m c = \/ r e s p o n s i v e _ s a m p l e .j p g / ) ) ;
117+ } ) ;
118+ it ( 'should support unicode URLs' , ( ) => {
119+ const img = des [ 1 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
120+ expect ( img . src ) . toEqual ( jasmine . stringMatching (
121+ new RegExp ( 'l_fetch:aHR0cHM6Ly91cGxvYWQud2lraW1lZGlhLm9yZy93aWtpcGVkaWEvY29tbW9ucy8yLzJiLyVFQSVCMyVB' +
122+ 'MCVFQyVCMCVCRCVFQSVCMCVBRiVFQiVCMiU4Qy5qcGc=/u_fetch:aHR0cHM6Ly91cGxvYWQud2lraW1lZGlhLm9yZy93aWtpcGVkaWEv' +
123+ 'Y29tbW9ucy8yLzJiLyVFQSVCMyVBMCVFQyVCMCVCRCVFQSVCMCVBRiVFQiVCMiU4Qy5qcGc=/responsive_sample.jpg' ) ) ) ;
124+ expect ( img . attributes . getNamedItem ( 'data-src' ) . value ) . toEqual ( jasmine . stringMatching (
125+ new RegExp ( 'l_fetch:aHR0cHM6Ly91cGxvYWQud2lraW1lZGlhLm9yZy93aWtpcGVkaWEvY29tbW9ucy8yLzJiLyVFQSVCMyVB' +
126+ 'MCVFQyVCMCVCRCVFQSVCMCVBRiVFQiVCMiU4Qy5qcGc=/u_fetch:aHR0cHM6Ly91cGxvYWQud2lraW1lZGlhLm9yZy93aWtpcGVkaWEv' +
127+ 'Y29tbW9ucy8yLzJiLyVFQSVCMyVBMCVFQyVCMCVCRCVFQSVCMCVBRiVFQiVCMiU4Qy5qcGc=/responsive_sample.jpg' ) ) ) ;
128+ } ) ;
129+ } ) ;
130+
84131 describe ( 'missing public-id' , ( ) => {
85132 @Component ( {
86133 template : '<cl-image responsive id="image1"></cl-image>'
0 commit comments