@@ -7,6 +7,9 @@ import { CloudinaryImage } from './cloudinary-image.component';
77import { CloudinaryTransformationDirective } from './cloudinary-transformation.directive' ;
88import { LazyLoadDirective } from './cloudinary-lazy-load.directive' ;
99import { CloudinaryPlaceHolder } from './cloudinary-placeholder.component' ;
10+ import { SDKAnalyticsConstants } from './SDKAnalyticsConstants' ;
11+ import { APP_VERSION } from './version' ;
12+
1013
1114describe ( 'Tests for sdk versionID on image tag' , ( ) => {
1215 describe ( 'Config with urlAnalytics not set' , ( ) => {
@@ -17,6 +20,7 @@ describe('Tests for sdk versionID on image tag', () => {
1720 spyOn ( localCloudinary , 'toCloudinaryAttributes' ) . and . callThrough ( ) ;
1821 spyOn ( localCloudinary , 'url' ) . and . callThrough ( ) ;
1922 spyOn ( localCloudinary , 'responsive' ) . and . callThrough ( ) ;
23+
2024 } ) ;
2125 @Component ( {
2226 template : `<cl-image responsive public-id="sample"></cl-image>`
@@ -50,9 +54,15 @@ describe('Tests for sdk versionID on image tag', () => {
5054 { cloud_name : '@@fake_angular_sdk@@' , urlAnalytics : true } as CloudinaryConfiguration ) ;
5155
5256 beforeEach ( ( ) => {
57+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
5358 spyOn ( localCloudinary , 'toCloudinaryAttributes' ) . and . callThrough ( ) ;
5459 spyOn ( localCloudinary , 'url' ) . and . callThrough ( ) ;
5560 } ) ;
61+
62+ afterEach ( ( ) => {
63+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
64+ } ) ;
65+
5666 @Component ( {
5767 template : `<cl-image public-id="sample"></cl-image>`
5868 } )
@@ -62,6 +72,7 @@ describe('Tests for sdk versionID on image tag', () => {
6272 let des : DebugElement ; // the elements w/ the directive
6373
6474 beforeEach ( ( ) => {
75+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
6576 fixture = TestBed . configureTestingModule ( {
6677 declarations : [ CloudinaryImage , TestComponent ] ,
6778 providers : [ { provide : Cloudinary , useValue : localCloudinary } ]
@@ -73,6 +84,10 @@ describe('Tests for sdk versionID on image tag', () => {
7384 des = fixture . debugElement . query ( By . directive ( CloudinaryImage ) ) ;
7485 } ) ;
7586
87+ afterEach ( ( ) => {
88+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
89+ } ) ;
90+
7691 it ( 'creates an img without a feature- resulting in 0' , ( ) => {
7792 const img = des . children [ 0 ] . nativeElement as HTMLImageElement ;
7893 expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( 'http://res.cloudinary.com/@@fake_angular_sdk@@/image/upload/sample?_a=AKHZdAH0' ) ;
@@ -84,9 +99,16 @@ describe('Tests for sdk versionID on image tag', () => {
8499 { cloud_name : '@@fake_angular_sdk@@' , urlAnalytics : true } as CloudinaryConfiguration ) ;
85100
86101 beforeEach ( ( ) => {
102+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
87103 spyOn ( localCloudinary , 'toCloudinaryAttributes' ) . and . callThrough ( ) ;
88104 spyOn ( localCloudinary , 'url' ) . and . callThrough ( ) ;
105+ spyOn ( SDKAnalyticsConstants , 'sdkSemver' ) . and . returnValue ( '1.3.3' ) ;
89106 } ) ;
107+
108+ afterEach ( ( ) => {
109+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
110+ } ) ;
111+
90112 @Component ( {
91113 template : `<cl-image accessibility="darkmode" public-id="sample"></cl-image>`
92114 } )
@@ -96,6 +118,7 @@ describe('Tests for sdk versionID on image tag', () => {
96118 let des : DebugElement ; // the elements w/ the directive
97119
98120 beforeEach ( ( ) => {
121+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
99122 fixture = TestBed . configureTestingModule ( {
100123 declarations : [ CloudinaryImage , TestComponent ] ,
101124 providers : [ { provide : Cloudinary , useValue : localCloudinary } ]
@@ -107,6 +130,10 @@ describe('Tests for sdk versionID on image tag', () => {
107130 des = fixture . debugElement . query ( By . directive ( CloudinaryImage ) ) ;
108131 } ) ;
109132
133+ afterEach ( ( ) => {
134+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
135+ } ) ;
136+
110137 it ( 'creates an img with feature accessibility D' , ( ) => {
111138 const img = des . children [ 0 ] . nativeElement as HTMLImageElement ;
112139 expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( 'http://res.cloudinary.com/@@fake_angular_sdk@@/image/upload/e_tint:75:black/sample?_a=AKHZdAHD' ) ;
@@ -118,10 +145,16 @@ describe('Tests for sdk versionID on image tag', () => {
118145 { cloud_name : '@@fake_angular_sdk@@' , urlAnalytics : true } as CloudinaryConfiguration ) ;
119146
120147 beforeEach ( ( ) => {
148+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
121149 spyOn ( localCloudinary , 'toCloudinaryAttributes' ) . and . callThrough ( ) ;
122150 spyOn ( localCloudinary , 'url' ) . and . callThrough ( ) ;
123151 spyOn ( localCloudinary , 'responsive' ) . and . callThrough ( ) ;
124152 } ) ;
153+
154+ afterEach ( ( ) => {
155+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
156+ } ) ;
157+
125158 @Component ( {
126159 template : `<cl-image responsive public-id="sample"></cl-image>`
127160 } )
@@ -131,6 +164,7 @@ describe('Tests for sdk versionID on image tag', () => {
131164 let des : DebugElement ; // the elements w/ the directive
132165
133166 beforeEach ( ( ) => {
167+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
134168 fixture = TestBed . configureTestingModule ( {
135169 declarations : [ CloudinaryImage , TestComponent ] ,
136170 providers : [ { provide : Cloudinary , useValue : localCloudinary } ]
@@ -143,6 +177,10 @@ describe('Tests for sdk versionID on image tag', () => {
143177 des = fixture . debugElement . query ( By . directive ( CloudinaryImage ) ) ;
144178 } ) ;
145179
180+ afterEach ( ( ) => {
181+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
182+ } ) ;
183+
146184 it ( 'creates an img with feature responsive A' , ( ) => {
147185 const img = des . children [ 0 ] . nativeElement as HTMLImageElement ;
148186 expect ( img . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( 'http://res.cloudinary.com/@@fake_angular_sdk@@/image/upload/sample?_a=AKHZdAHA' ) ;
@@ -162,6 +200,7 @@ describe('Tests for sdk versionID on image tag', () => {
162200 let testLocalCloudinary : Cloudinary = new Cloudinary ( require ( 'cloudinary-core' ) ,
163201 { cloud_name : '@@fake_angular_sdk@@' , urlAnalytics : true } as CloudinaryConfiguration ) ;
164202 beforeEach ( fakeAsync ( ( ) => {
203+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
165204 fixture = TestBed . configureTestingModule ( {
166205 declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent , LazyLoadDirective , CloudinaryPlaceHolder ] ,
167206 providers : [ { provide : Cloudinary , useValue : testLocalCloudinary } ]
@@ -174,6 +213,9 @@ describe('Tests for sdk versionID on image tag', () => {
174213 tick ( ) ;
175214 fixture . detectChanges ( ) ;
176215 } ) ) ;
216+ afterEach ( ( ) => {
217+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
218+ } ) ;
177219 it ( 'placeholder img should encode with B' , async ( ) => {
178220 const placeholderimg = placeholder [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
179221 expect ( placeholderimg . attributes . getNamedItem ( 'src' ) . value ) . toEqual ( 'http://res.cloudinary.com/@@fake_angular_sdk@@/image/upload/e_blur:2000,f_auto,q_1/sample?_a=AKHZdAHB' ) ;
@@ -195,6 +237,7 @@ describe('Tests for sdk versionID on image tag', () => {
195237 let testLocalCloudinary : Cloudinary = new Cloudinary ( require ( 'cloudinary-core' ) ,
196238 { cloud_name : '@@fake_angular_sdk@@' , urlAnalytics : true } as CloudinaryConfiguration ) ;
197239 beforeEach ( fakeAsync ( ( ) => {
240+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
198241 fixture = TestBed . configureTestingModule ( {
199242 declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent , LazyLoadDirective , CloudinaryPlaceHolder ] ,
200243 providers : [ { provide : Cloudinary , useValue : testLocalCloudinary } ]
@@ -207,6 +250,9 @@ describe('Tests for sdk versionID on image tag', () => {
207250 tick ( ) ;
208251 fixture . detectChanges ( ) ;
209252 } ) ) ;
253+ afterEach ( ( ) => {
254+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
255+ } ) ;
210256 it ( 'creates an img with feature lazy load C' , async ( ) => {
211257 const wait = ( ms ) => new Promise ( res => setTimeout ( res , ms ) ) ;
212258 await wait ( 300 ) ;
0 commit comments