@@ -341,6 +341,39 @@ describe('CloudinaryImage', () => {
341341 } ) ;
342342 } ) ;
343343
344+ describe ( 'should support user variables with keyword $width' , ( ) => {
345+ @Component ( {
346+ template :
347+ `
348+ <cl-image public-id="sample">
349+ <cl-transformation variables="[['$width','150']]"></cl-transformation>
350+ <cl-transformation width="$width" crop="crop" ></cl-transformation>
351+ </cl-image>
352+ `
353+ } )
354+ class TestComponent { }
355+
356+ let fixture : ComponentFixture < TestComponent > ;
357+ let des : DebugElement ; // the elements w/ the directive
358+
359+ beforeEach ( ( ) => {
360+ fixture = TestBed . configureTestingModule ( {
361+ declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent ] ,
362+ providers : [ { provide : Cloudinary , useValue : localCloudinary } ]
363+ } ) . createComponent ( TestComponent ) ;
364+
365+ fixture . detectChanges ( ) ; // initial binding
366+
367+ // Our element under test, which is attached to CloudinaryImage
368+ des = fixture . debugElement . query ( By . directive ( CloudinaryImage ) ) ;
369+ } ) ;
370+
371+ it ( 'creates an img element with user variables $width' , ( ) => {
372+ const img = des . children [ 0 ] . nativeElement as HTMLImageElement ;
373+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( 'http://res.cloudinary.com/@@fake_angular2_sdk@@/image/upload/$width_150/c_crop,w_$width/sample' ) ;
374+ } ) ;
375+ } ) ;
376+
344377 describe ( 'Sample code presented in README' , ( ) => {
345378 @Component ( {
346379 template :
0 commit comments