@@ -308,6 +308,39 @@ describe('CloudinaryImage', () => {
308308 } ) ;
309309 } ) ;
310310
311+ describe ( 'should support user variables' , ( ) => {
312+ @Component ( {
313+ template :
314+ `
315+ <cl-image public-id="sample">
316+ <cl-transformation variables="[['$imgWidth','150']]"></cl-transformation>
317+ <cl-transformation width="$imgWidth" crop="crop" ></cl-transformation>
318+ </cl-image>
319+ `
320+ } )
321+ class TestComponent { }
322+
323+ let fixture : ComponentFixture < TestComponent > ;
324+ let des : DebugElement ; // the elements w/ the directive
325+
326+ beforeEach ( ( ) => {
327+ fixture = TestBed . configureTestingModule ( {
328+ declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent ] ,
329+ providers : [ { provide : Cloudinary , useValue : localCloudinary } ]
330+ } ) . createComponent ( TestComponent ) ;
331+
332+ fixture . detectChanges ( ) ; // initial binding
333+
334+ // Our element under test, which is attached to CloudinaryImage
335+ des = fixture . debugElement . query ( By . directive ( CloudinaryImage ) ) ;
336+ } ) ;
337+
338+ it ( 'creates an img element with user variables' , ( ) => {
339+ const img = des . children [ 0 ] . nativeElement as HTMLImageElement ;
340+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( 'http://res.cloudinary.com/@@fake_angular2_sdk@@/image/upload/$imgWidth_150/c_crop,w_$imgWidth/sample' ) ;
341+ } ) ;
342+ } ) ;
343+
311344 describe ( 'Sample code presented in README' , ( ) => {
312345 @Component ( {
313346 template :
0 commit comments