@@ -527,6 +527,63 @@ describe('CloudinaryImage', () => {
527527 } ) ;
528528 } ) ;
529529
530+ describe ( 'cl-image styling without placeholder' , ( ) => {
531+ @Component ( {
532+ template : `<cl-image public-id="sample.jpg" ></cl-image>`
533+ } )
534+ class TestComponent { }
535+
536+ let fixture : ComponentFixture < TestComponent > ;
537+ let des : DebugElement [ ] ; // the elements w/ the directive
538+ let testLocalCloudinary : Cloudinary = new Cloudinary ( require ( 'cloudinary-core' ) ,
539+ { cloud_name : '@@fake_angular2_sdk@@' , client_hints : true } as CloudinaryConfiguration ) ;
540+ beforeEach ( ( ) => {
541+ fixture = TestBed . configureTestingModule ( {
542+ declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent ] ,
543+ providers : [ { provide : Cloudinary , useValue : testLocalCloudinary } ]
544+ } ) . createComponent ( TestComponent ) ;
545+
546+ fixture . detectChanges ( ) ; // initial binding
547+ // all elements with an attached CloudinaryImage
548+ des = fixture . debugElement . queryAll ( By . directive ( CloudinaryImage ) ) ;
549+ } ) ;
550+
551+ it ( 'should not have style opacity and position' , ( ) => {
552+ const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
553+ expect ( img . getAttribute ( 'style' ) ) . toEqual ( jasmine . stringMatching ( '' ) ) ;
554+ } ) ;
555+ } ) ;
556+
557+ describe ( 'cl-image styling with placeholder' , ( ) => {
558+ @Component ( {
559+ template : `<div style="margin-top: 4000px"></div>
560+ <cl-image public-id="sample.jpg" loading="lazy">
561+ <cl-placeholder></cl-placeholder>
562+ </cl-image>`
563+ } )
564+ class TestComponent { }
565+
566+ let fixture : ComponentFixture < TestComponent > ;
567+ let des : DebugElement [ ] ; // the elements w/ the directive
568+ let testLocalCloudinary : Cloudinary = new Cloudinary ( require ( 'cloudinary-core' ) ,
569+ { cloud_name : '@@fake_angular2_sdk@@' , client_hints : true } as CloudinaryConfiguration ) ;
570+ beforeEach ( ( ) => {
571+ fixture = TestBed . configureTestingModule ( {
572+ declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent , CloudinaryPlaceHolder ] ,
573+ providers : [ { provide : Cloudinary , useValue : testLocalCloudinary } ]
574+ } ) . createComponent ( TestComponent ) ;
575+
576+ fixture . detectChanges ( ) ; // initial binding
577+ // all elements with an attached CloudinaryImage
578+ des = fixture . debugElement . queryAll ( By . directive ( CloudinaryImage ) ) ;
579+ } ) ;
580+
581+ it ( 'should have style opacity and position' , ( ) => {
582+ const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
583+ expect ( img . getAttribute ( 'style' ) ) . toEqual ( jasmine . stringMatching ( 'opacity: 0; position: absolute;' ) ) ;
584+ } ) ;
585+ } ) ;
586+
530587 describe ( 'lazy load image' , async ( ) => {
531588 @Component ( {
532589 template : `
0 commit comments