@@ -855,4 +855,67 @@ describe('CloudinaryImage', () => {
855855 expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'e_sepia/c_fit,w_30/e_blur:2000,f_auto,q_1/bear' ) ) ;
856856 } ) ) ;
857857 } ) ;
858+ describe ( 'cl-image with acessibility modes' , ( ) => {
859+ @Component ( {
860+ template : `<cl-image public-id="bear" accessibility="darkmode"></cl-image>
861+ <cl-image public-id="bear" accessibility="monochrome"></cl-image>
862+ <cl-image public-id="bear" accessibility="brightmode"></cl-image>
863+ <cl-image public-id="bear" accessibility="colorblind"></cl-image>`
864+ } )
865+ class TestComponent { }
866+
867+ let fixture : ComponentFixture < TestComponent > ;
868+ let des : DebugElement [ ] ; // the elements w/ the directive
869+ let testLocalCloudinary : Cloudinary = new Cloudinary ( require ( 'cloudinary-core' ) ,
870+ { cloud_name : '@@fake_angular2_sdk@@' , client_hints : true } as CloudinaryConfiguration ) ;
871+ beforeEach ( ( ) => {
872+ fixture = TestBed . configureTestingModule ( {
873+ declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent ] ,
874+ providers : [ { provide : Cloudinary , useValue : testLocalCloudinary } ]
875+ } ) . createComponent ( TestComponent ) ;
876+ fixture . detectChanges ( ) ; // initial binding
877+ des = fixture . debugElement . queryAll ( By . directive ( CloudinaryImage ) ) ;
878+ } ) ;
879+ it ( 'creates an img element with accessibility darkmode' , fakeAsync ( ( ) => {
880+ const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
881+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'e_tint:75:black/bear' ) ) ;
882+ } ) ) ;
883+ it ( 'creates an img element with accessibility monochrome' , fakeAsync ( ( ) => {
884+ const img = des [ 1 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
885+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'e_grayscale/bear' ) ) ;
886+ } ) ) ;
887+ it ( 'creates an img element with accessibility brightmode' , fakeAsync ( ( ) => {
888+ const img = des [ 2 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
889+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'e_tint:50:white/bear' ) ) ;
890+ } ) ) ;
891+ it ( 'creates an img element with accessibility colorblind' , fakeAsync ( ( ) => {
892+ const img = des [ 3 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
893+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'e_assist_colorblind/bear' ) ) ;
894+ } ) ) ;
895+ } ) ;
896+ describe ( 'cl-image with acessibility modes and transformation' , ( ) => {
897+ @Component ( {
898+ template : `<cl-image public-id="bear" accessibility="darkmode" effect="grayscale" overlay="sample">
899+ <cl-transformation effect="sepia"></cl-transformation>
900+ </cl-image>`
901+ } )
902+ class TestComponent { }
903+
904+ let fixture : ComponentFixture < TestComponent > ;
905+ let des : DebugElement [ ] ; // the elements w/ the directive
906+ let testLocalCloudinary : Cloudinary = new Cloudinary ( require ( 'cloudinary-core' ) ,
907+ { cloud_name : '@@fake_angular2_sdk@@' , client_hints : true } as CloudinaryConfiguration ) ;
908+ beforeEach ( ( ) => {
909+ fixture = TestBed . configureTestingModule ( {
910+ declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent ] ,
911+ providers : [ { provide : Cloudinary , useValue : testLocalCloudinary } ]
912+ } ) . createComponent ( TestComponent ) ;
913+ fixture . detectChanges ( ) ; // initial binding
914+ des = fixture . debugElement . queryAll ( By . directive ( CloudinaryImage ) ) ;
915+ } ) ;
916+ it ( 'creates an img element with accessibility darkmode without overwriting effect' , fakeAsync ( ( ) => {
917+ const img = des [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
918+ expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( jasmine . stringMatching ( 'e_sepia/e_grayscale,l_sample/e_tint:75:black/bear' ) ) ;
919+ } ) ) ;
920+ } ) ;
858921} ) ;
0 commit comments