@@ -7,6 +7,9 @@ import { CloudinaryImage } from './cloudinary-image.component';
7
7
import { CloudinaryTransformationDirective } from './cloudinary-transformation.directive' ;
8
8
import { LazyLoadDirective } from './cloudinary-lazy-load.directive' ;
9
9
import { CloudinaryPlaceHolder } from './cloudinary-placeholder.component' ;
10
+ import { SDKAnalyticsConstants } from './SDKAnalyticsConstants' ;
11
+ import { APP_VERSION } from './version' ;
12
+
10
13
11
14
describe ( 'Tests for sdk versionID on image tag' , ( ) => {
12
15
describe ( 'Config with urlAnalytics not set' , ( ) => {
@@ -17,6 +20,7 @@ describe('Tests for sdk versionID on image tag', () => {
17
20
spyOn ( localCloudinary , 'toCloudinaryAttributes' ) . and . callThrough ( ) ;
18
21
spyOn ( localCloudinary , 'url' ) . and . callThrough ( ) ;
19
22
spyOn ( localCloudinary , 'responsive' ) . and . callThrough ( ) ;
23
+
20
24
} ) ;
21
25
@Component ( {
22
26
template : `<cl-image responsive public-id="sample"></cl-image>`
@@ -50,9 +54,15 @@ describe('Tests for sdk versionID on image tag', () => {
50
54
{ cloud_name : '@@fake_angular_sdk@@' , urlAnalytics : true } as CloudinaryConfiguration ) ;
51
55
52
56
beforeEach ( ( ) => {
57
+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
53
58
spyOn ( localCloudinary , 'toCloudinaryAttributes' ) . and . callThrough ( ) ;
54
59
spyOn ( localCloudinary , 'url' ) . and . callThrough ( ) ;
55
60
} ) ;
61
+
62
+ afterEach ( ( ) => {
63
+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
64
+ } ) ;
65
+
56
66
@Component ( {
57
67
template : `<cl-image public-id="sample"></cl-image>`
58
68
} )
@@ -62,6 +72,7 @@ describe('Tests for sdk versionID on image tag', () => {
62
72
let des : DebugElement ; // the elements w/ the directive
63
73
64
74
beforeEach ( ( ) => {
75
+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
65
76
fixture = TestBed . configureTestingModule ( {
66
77
declarations : [ CloudinaryImage , TestComponent ] ,
67
78
providers : [ { provide : Cloudinary , useValue : localCloudinary } ]
@@ -73,6 +84,10 @@ describe('Tests for sdk versionID on image tag', () => {
73
84
des = fixture . debugElement . query ( By . directive ( CloudinaryImage ) ) ;
74
85
} ) ;
75
86
87
+ afterEach ( ( ) => {
88
+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
89
+ } ) ;
90
+
76
91
it ( 'creates an img without a feature- resulting in 0' , ( ) => {
77
92
const img = des . children [ 0 ] . nativeElement as HTMLImageElement ;
78
93
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', () => {
84
99
{ cloud_name : '@@fake_angular_sdk@@' , urlAnalytics : true } as CloudinaryConfiguration ) ;
85
100
86
101
beforeEach ( ( ) => {
102
+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
87
103
spyOn ( localCloudinary , 'toCloudinaryAttributes' ) . and . callThrough ( ) ;
88
104
spyOn ( localCloudinary , 'url' ) . and . callThrough ( ) ;
105
+ spyOn ( SDKAnalyticsConstants , 'sdkSemver' ) . and . returnValue ( '1.3.3' ) ;
89
106
} ) ;
107
+
108
+ afterEach ( ( ) => {
109
+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
110
+ } ) ;
111
+
90
112
@Component ( {
91
113
template : `<cl-image accessibility="darkmode" public-id="sample"></cl-image>`
92
114
} )
@@ -96,6 +118,7 @@ describe('Tests for sdk versionID on image tag', () => {
96
118
let des : DebugElement ; // the elements w/ the directive
97
119
98
120
beforeEach ( ( ) => {
121
+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
99
122
fixture = TestBed . configureTestingModule ( {
100
123
declarations : [ CloudinaryImage , TestComponent ] ,
101
124
providers : [ { provide : Cloudinary , useValue : localCloudinary } ]
@@ -107,6 +130,10 @@ describe('Tests for sdk versionID on image tag', () => {
107
130
des = fixture . debugElement . query ( By . directive ( CloudinaryImage ) ) ;
108
131
} ) ;
109
132
133
+ afterEach ( ( ) => {
134
+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
135
+ } ) ;
136
+
110
137
it ( 'creates an img with feature accessibility D' , ( ) => {
111
138
const img = des . children [ 0 ] . nativeElement as HTMLImageElement ;
112
139
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', () => {
118
145
{ cloud_name : '@@fake_angular_sdk@@' , urlAnalytics : true } as CloudinaryConfiguration ) ;
119
146
120
147
beforeEach ( ( ) => {
148
+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
121
149
spyOn ( localCloudinary , 'toCloudinaryAttributes' ) . and . callThrough ( ) ;
122
150
spyOn ( localCloudinary , 'url' ) . and . callThrough ( ) ;
123
151
spyOn ( localCloudinary , 'responsive' ) . and . callThrough ( ) ;
124
152
} ) ;
153
+
154
+ afterEach ( ( ) => {
155
+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
156
+ } ) ;
157
+
125
158
@Component ( {
126
159
template : `<cl-image responsive public-id="sample"></cl-image>`
127
160
} )
@@ -131,6 +164,7 @@ describe('Tests for sdk versionID on image tag', () => {
131
164
let des : DebugElement ; // the elements w/ the directive
132
165
133
166
beforeEach ( ( ) => {
167
+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
134
168
fixture = TestBed . configureTestingModule ( {
135
169
declarations : [ CloudinaryImage , TestComponent ] ,
136
170
providers : [ { provide : Cloudinary , useValue : localCloudinary } ]
@@ -143,6 +177,10 @@ describe('Tests for sdk versionID on image tag', () => {
143
177
des = fixture . debugElement . query ( By . directive ( CloudinaryImage ) ) ;
144
178
} ) ;
145
179
180
+ afterEach ( ( ) => {
181
+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
182
+ } ) ;
183
+
146
184
it ( 'creates an img with feature responsive A' , ( ) => {
147
185
const img = des . children [ 0 ] . nativeElement as HTMLImageElement ;
148
186
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', () => {
162
200
let testLocalCloudinary : Cloudinary = new Cloudinary ( require ( 'cloudinary-core' ) ,
163
201
{ cloud_name : '@@fake_angular_sdk@@' , urlAnalytics : true } as CloudinaryConfiguration ) ;
164
202
beforeEach ( fakeAsync ( ( ) => {
203
+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
165
204
fixture = TestBed . configureTestingModule ( {
166
205
declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent , LazyLoadDirective , CloudinaryPlaceHolder ] ,
167
206
providers : [ { provide : Cloudinary , useValue : testLocalCloudinary } ]
@@ -174,6 +213,9 @@ describe('Tests for sdk versionID on image tag', () => {
174
213
tick ( ) ;
175
214
fixture . detectChanges ( ) ;
176
215
} ) ) ;
216
+ afterEach ( ( ) => {
217
+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
218
+ } ) ;
177
219
it ( 'placeholder img should encode with B' , async ( ) => {
178
220
const placeholderimg = placeholder [ 0 ] . children [ 0 ] . nativeElement as HTMLImageElement ;
179
221
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', () => {
195
237
let testLocalCloudinary : Cloudinary = new Cloudinary ( require ( 'cloudinary-core' ) ,
196
238
{ cloud_name : '@@fake_angular_sdk@@' , urlAnalytics : true } as CloudinaryConfiguration ) ;
197
239
beforeEach ( fakeAsync ( ( ) => {
240
+ SDKAnalyticsConstants . sdkSemver = '1.3.3' ;
198
241
fixture = TestBed . configureTestingModule ( {
199
242
declarations : [ CloudinaryTransformationDirective , CloudinaryImage , TestComponent , LazyLoadDirective , CloudinaryPlaceHolder ] ,
200
243
providers : [ { provide : Cloudinary , useValue : testLocalCloudinary } ]
@@ -207,6 +250,9 @@ describe('Tests for sdk versionID on image tag', () => {
207
250
tick ( ) ;
208
251
fixture . detectChanges ( ) ;
209
252
} ) ) ;
253
+ afterEach ( ( ) => {
254
+ SDKAnalyticsConstants . sdkSemver = APP_VERSION ;
255
+ } ) ;
210
256
it ( 'creates an img with feature lazy load C' , async ( ) => {
211
257
const wait = ( ms ) => new Promise ( res => setTimeout ( res , ms ) ) ;
212
258
await wait ( 300 ) ;
0 commit comments