@@ -128,6 +128,46 @@ describe('CloudinaryImage', () => {
128128 } ) ;
129129 } ) ;
130130
131+ describe ( 'transformation attributes: quality' , ( ) => {
132+ @Component ( {
133+ template : `
134+ <cl-image responsive id="image1" public-id="responsive_sample.jpg">
135+ <cl-transformation quality="0.4"></cl-transformation>
136+ </cl-image>
137+ <cl-image responsive id="image2" public-id="responsive_sample.jpg">
138+ <cl-transformation quality="auto"></cl-transformation>
139+ </cl-image>
140+ <cl-image responsive id="image3" public-id="responsive_sample.jpg">
141+ <cl-transformation quality="auto:good"></cl-transformation>
142+ </cl-image>
143+ `
144+ } )
145+ class TestComponent { }
146+
147+ let fixture : ComponentFixture < TestComponent > ;
148+ let des : DebugElement [ ] ; // the elements w/ the directive
149+
150+ beforeEach ( ( ) => {
151+ fixture = TestBed . configureTestingModule ( {
152+ declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent ] ,
153+ providers : [ { provide : Cloudinary , useValue : localCloudinary } ]
154+ } ) . createComponent ( TestComponent ) ;
155+
156+ fixture . detectChanges ( ) ; // initial binding
157+
158+ // all elements with an attached CloudinaryImage
159+ des = fixture . debugElement . queryAll ( By . directive ( CloudinaryImage ) ) ;
160+ } ) ;
161+
162+ it ( 'creates an img element which encodes the quality parameter to URL' , ( ) => {
163+ const testResults = [ 'q_0.4' , 'q_auto' , 'q_auto:good' ] ;
164+ testResults . forEach ( ( result , index ) => {
165+ const img = des [ index ] . children [ 0 ] . nativeElement as HTMLImageElement ;
166+ expect ( img . src ) . toEqual ( jasmine . stringMatching ( new RegExp ( `\/${ result } \/responsive_sample.jpg` ) ) ) ;
167+ } ) ;
168+ } ) ;
169+ } ) ;
170+
131171 describe ( 'missing public-id' , ( ) => {
132172 @Component ( {
133173 template : '<cl-image responsive id="image1"></cl-image>'
0 commit comments