@@ -649,18 +649,12 @@ describe('CloudinaryImage', () => {
649649 expect ( img . getAttribute ( 'style' ) ) . toEqual ( jasmine . stringMatching ( 'opacity: 0; position: absolute;' ) ) ;
650650 } ) ;
651651 } ) ;
652-
653- describe ( 'lazy load image' , async ( ) => {
652+ describe ( 'cl-image with placeholder and html style' , ( ) => {
654653 @Component ( {
655- template : `
656- <div class="startWindow"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
657- <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
658- <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
659- <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
660- <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
661- <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
662- <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
663- <div class="endWindow" style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>`
654+ template : `<div style="margin-top: 4000px"></div>
655+ <cl-image loading="lazy" public-id="sample" width="500" crop="fit" style="max-height: 100%">
656+ <cl-placeholder type="blur"></cl-placeholder>
657+ </cl-image>`
664658 } )
665659 class TestComponent { }
666660
@@ -670,7 +664,7 @@ describe('CloudinaryImage', () => {
670664 { cloud_name : '@@fake_angular2_sdk@@' , client_hints : true } as CloudinaryConfiguration ) ;
671665 beforeEach ( ( ) => {
672666 fixture = TestBed . configureTestingModule ( {
673- declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent , LazyLoadDirective ] ,
667+ declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent , CloudinaryPlaceHolder ] ,
674668 providers : [ { provide : Cloudinary , useValue : testLocalCloudinary } ]
675669 } ) . createComponent ( TestComponent ) ;
676670
@@ -679,43 +673,17 @@ describe('CloudinaryImage', () => {
679673 des = fixture . debugElement . queryAll ( By . directive ( CloudinaryImage ) ) ;
680674 } ) ;
681675
682- it ( 'should load eagerly ' , ( ) => {
676+ it ( 'should have style opacity and position when style is passed ' , ( ) => {
683677 const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
684- expect ( img . hasAttribute ( 'data-src' ) ) . toBe ( true ) ;
685- expect ( img . attributes . getNamedItem ( 'data-src' ) . value ) . toEqual ( jasmine . stringMatching ( 'image/upload/bear' ) ) ;
686- } ) ;
687- it ( 'Should lazy load post scroll' , async ( ) => {
688- const delay = 300 ;
689- const wait = ( ms ) => new Promise ( res => setTimeout ( res , ms ) ) ;
690- const count = async ( ) => document . querySelectorAll ( '.startWindow' ) . length ;
691- const scrollDown = async ( ) => {
692- document . querySelector ( '.endWindow' )
693- . scrollIntoView ( { behavior : 'smooth' , block : 'end' , inline : 'end' } ) ;
694- }
695-
696- let preCount = 0 ;
697- let postCount = 0 ;
698- do {
699- preCount = await count ( ) ;
700- await scrollDown ( ) ;
701- await wait ( delay ) ;
702- postCount = await count ( ) ;
703- } while ( postCount > preCount ) ;
704- await wait ( delay ) ;
705-
706- const img = des [ 3 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
707- expect ( img . hasAttribute ( 'src' ) ) . toBe ( true ) ;
708- expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'image/upload/bear' ) ) ;
678+ expect ( img . getAttribute ( 'style' ) ) . toEqual ( jasmine . stringMatching ( 'max-height: 100%; opacity: 0; position: absolute;' ) ) ;
709679 } ) ;
710680 } ) ;
711- describe ( 'lazy load image with default placeholder ' , async ( ) => {
681+ describe ( 'lazy load image' , async ( ) => {
712682 @Component ( {
713683 template : `
714684 <div class="startWindow"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
715685 <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
716- <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear">
717- <cl-placeholder></cl-placeholder>
718- </cl-image></div>
686+ <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
719687 <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
720688 <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
721689 <div style="margin-top: 300px"><cl-image loading="lazy" width="300" public-id="bear"></cl-image></div>
@@ -726,28 +694,25 @@ describe('CloudinaryImage', () => {
726694
727695 let fixture : ComponentFixture < TestComponent > ;
728696 let des : DebugElement [ ] ; // the elements w/ the directive
729- let placeholder : DebugElement [ ] ;
730697 let testLocalCloudinary : Cloudinary = new Cloudinary ( require ( 'cloudinary-core' ) ,
731698 { cloud_name : '@@fake_angular2_sdk@@' , client_hints : true } as CloudinaryConfiguration ) ;
732- beforeEach ( fakeAsync ( ( ) => {
699+ beforeEach ( ( ) => {
733700 fixture = TestBed . configureTestingModule ( {
734- declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent , LazyLoadDirective , CloudinaryPlaceHolder ] ,
701+ declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent , LazyLoadDirective ] ,
735702 providers : [ { provide : Cloudinary , useValue : testLocalCloudinary } ]
736703 } ) . createComponent ( TestComponent ) ;
737704
738705 fixture . detectChanges ( ) ; // initial binding
739706 // all elements with an attached CloudinaryImage
740707 des = fixture . debugElement . queryAll ( By . directive ( CloudinaryImage ) ) ;
741- placeholder = fixture . debugElement . queryAll ( By . directive ( CloudinaryPlaceHolder ) ) ;
742- tick ( ) ;
743- fixture . detectChanges ( ) ;
744- } ) ) ;
708+ } ) ;
709+
745710 it ( 'should load eagerly' , ( ) => {
746711 const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
747712 expect ( img . hasAttribute ( 'data-src' ) ) . toBe ( true ) ;
748713 expect ( img . attributes . getNamedItem ( 'data-src' ) . value ) . toEqual ( jasmine . stringMatching ( 'image/upload/bear' ) ) ;
749714 } ) ;
750- it ( 'Should lazy load post scroll' , async ( ) => {
715+ it ( 'Should lazy load post scroll' , async ( ) => {
751716 const delay = 300 ;
752717 const wait = ( ms ) => new Promise ( res => setTimeout ( res , ms ) ) ;
753718 const count = async ( ) => document . querySelectorAll ( '.startWindow' ) . length ;
@@ -766,9 +731,7 @@ describe('CloudinaryImage', () => {
766731 } while ( postCount > preCount ) ;
767732 await wait ( delay ) ;
768733
769- const placeholderimg = placeholder [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
770734 const img = des [ 3 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
771- expect ( placeholderimg . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'image/upload/e_blur:2000,f_auto,q_1/bear' ) ) ;
772735 expect ( img . hasAttribute ( 'src' ) ) . toBe ( true ) ;
773736 expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'image/upload/bear' ) ) ;
774737 } ) ;
@@ -862,7 +825,7 @@ describe('CloudinaryImage', () => {
862825 tick ( ) ;
863826 fixture . detectChanges ( ) ;
864827 const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
865- expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'c_fit,w_30 /e_blur:2000,f_auto,q_1/bear' ) ) ;
828+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'c_fit,w_300 /e_blur:2000,f_auto,q_1/bear' ) ) ;
866829 } ) ) ;
867830 } ) ;
868831 describe ( 'placeholder type pixelate' , ( ) => {
@@ -890,7 +853,7 @@ describe('CloudinaryImage', () => {
890853 tick ( ) ;
891854 fixture . detectChanges ( ) ;
892855 const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
893- expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'image/upload/c_fit,w_30 /e_pixelate,f_auto,q_1/bear' ) ) ;
856+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'image/upload/c_fit,w_300 /e_pixelate,f_auto,q_1/bear' ) ) ;
894857 } ) ) ;
895858 } ) ;
896859 describe ( 'placeholder type predominant-color with exact dimensions' , ( ) => {
@@ -918,7 +881,7 @@ describe('CloudinaryImage', () => {
918881 tick ( ) ;
919882 fixture . detectChanges ( ) ;
920883 const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
921- expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'image/upload/c_fit,h_30,w_30 /ar_1,b_auto,' +
884+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'image/upload/c_fit,h_300,w_300 /ar_1,b_auto,' +
922885 'c_pad,w_iw_div_2/c_crop,g_north_east,h_1,w_1/f_auto,q_auto/bear' ) ) ;
923886 } ) ) ;
924887 } ) ;
@@ -948,7 +911,7 @@ describe('CloudinaryImage', () => {
948911 fixture . detectChanges ( ) ;
949912 const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
950913 expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( 'http://res.cloudinary.com/@@fake_angular2_sdk@@/image/' +
951- 'upload/c_fit,w_30 /$currWidth_w,$currHeight_h/ar_1,b_auto,c_pad,w_iw_div_2/c_crop,g_north_east,h_10,w_10/c_fill,h_$currHeight,w_$currWidth/f_auto,q_auto/bear' ) ;
914+ 'upload/c_fit,w_300 /$currWidth_w,$currHeight_h/ar_1,b_auto,c_pad,w_iw_div_2/c_crop,g_north_east,h_10,w_10/c_fill,h_$currHeight,w_$currWidth/f_auto,q_auto/bear' ) ;
952915 } ) ) ;
953916 } ) ;
954917 describe ( 'placeholder type vectorize' , ( ) => {
@@ -1004,7 +967,7 @@ describe('CloudinaryImage', () => {
1004967 tick ( ) ;
1005968 fixture . detectChanges ( ) ;
1006969 const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
1007- expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'e_sepia/c_fit,w_30 /e_blur:2000,f_auto,q_1/bear' ) ) ;
970+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'e_sepia/c_fit,w_300 /e_blur:2000,f_auto,q_1/bear' ) ) ;
1008971 } ) ) ;
1009972 } ) ;
1010973 describe ( 'cl-image with acessibility modes' , ( ) => {
0 commit comments