@purchasely/cordova-plugin-purchasely 6.0.0-rc.3 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Package.swift +77 -0
- package/README.md +22 -14
- package/package.json +11 -2
- package/plugin.xml +4 -4
- package/src/android/PurchaselyPlugin.kt +247 -67
- package/src/ios/CDVPurchasely+Events.m +7 -1
- package/src/ios/CDVPurchasely.h +11 -0
- package/src/ios/CDVPurchasely.m +180 -10
- package/src/ios/Hybrid/PLYPlan+Hybrid.m +19 -0
- package/src/ios/Hybrid/PLYSubscription+Hybrid.m +13 -0
- package/www/Purchasely.js +390 -46
- package/__tests__/Purchasely.test.js +0 -1161
- package/example/android.sh +0 -10
- package/example/config.xml +0 -27
- package/example/e2e/README.md +0 -44
- package/example/e2e/helpers/driver.js +0 -70
- package/example/e2e/package.json +0 -19
- package/example/e2e/specs/bridge.e2e.js +0 -51
- package/example/e2e/specs/dismiss.e2e.js +0 -37
- package/example/e2e/tools/ci_run_e2e.sh +0 -49
- package/example/e2e/tools/ci_run_e2e_ios.sh +0 -46
- package/example/e2e/wdio.android.conf.js +0 -21
- package/example/e2e/wdio.ios.conf.js +0 -19
- package/example/e2e/wdio.shared.conf.js +0 -28
- package/example/ios.sh +0 -16
- package/example/package-lock.json +0 -859
- package/example/package.json +0 -37
- package/example/www/css/index.css +0 -110
- package/example/www/img/logo.png +0 -0
- package/example/www/index.html +0 -78
- package/example/www/js/index.js +0 -449
- package/purchasely.iml +0 -11
|
@@ -1,1161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unit tests for Purchasely.js
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// Mock cordova/exec
|
|
6
|
-
const mockExec = jest.fn();
|
|
7
|
-
jest.mock('cordova/exec', () => mockExec, { virtual: true });
|
|
8
|
-
|
|
9
|
-
// Mock cordova global
|
|
10
|
-
global.cordova = {
|
|
11
|
-
define: {
|
|
12
|
-
moduleMap: {
|
|
13
|
-
'cordova/plugin_list': {
|
|
14
|
-
exports: {
|
|
15
|
-
metadata: {
|
|
16
|
-
'cordova-plugin-purchasely': '5.6.2'
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// Import the module after mocks are set up
|
|
25
|
-
const Purchasely = require('../www/Purchasely');
|
|
26
|
-
|
|
27
|
-
describe('Purchasely', () => {
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
mockExec.mockClear();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('Constants', () => {
|
|
33
|
-
describe('LogLevel', () => {
|
|
34
|
-
it('should have correct log level values', () => {
|
|
35
|
-
expect(Purchasely.LogLevel.DEBUG).toBe(0);
|
|
36
|
-
expect(Purchasely.LogLevel.INFO).toBe(1);
|
|
37
|
-
expect(Purchasely.LogLevel.WARN).toBe(2);
|
|
38
|
-
expect(Purchasely.LogLevel.ERROR).toBe(3);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe('Attribute', () => {
|
|
43
|
-
it('should have correct attribute values', () => {
|
|
44
|
-
expect(Purchasely.Attribute.FIREBASE_APP_INSTANCE_ID).toBe(0);
|
|
45
|
-
expect(Purchasely.Attribute.AIRSHIP_CHANNEL_ID).toBe(1);
|
|
46
|
-
expect(Purchasely.Attribute.ADJUST_ID).toBe(4);
|
|
47
|
-
expect(Purchasely.Attribute.APPSFLYER_ID).toBe(5);
|
|
48
|
-
expect(Purchasely.Attribute.AMPLITUDE_USER_ID).toBe(16);
|
|
49
|
-
expect(Purchasely.Attribute.BATCH_CUSTOM_USER_ID).toBe(20);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe('DataProcessingLegalBasis', () => {
|
|
54
|
-
it('should have correct legal basis values', () => {
|
|
55
|
-
expect(Purchasely.DataProcessingLegalBasis.essential).toBe('ESSENTIAL');
|
|
56
|
-
expect(Purchasely.DataProcessingLegalBasis.optional).toBe('OPTIONAL');
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
describe('DataProcessingPurpose', () => {
|
|
61
|
-
it('should have correct purpose values', () => {
|
|
62
|
-
expect(Purchasely.DataProcessingPurpose.allNonEssentials).toBe('ALL_NON_ESSENTIALS');
|
|
63
|
-
expect(Purchasely.DataProcessingPurpose.analytics).toBe('ANALYTICS');
|
|
64
|
-
expect(Purchasely.DataProcessingPurpose.identifiedAnalytics).toBe('IDENTIFIED_ANALYTICS');
|
|
65
|
-
expect(Purchasely.DataProcessingPurpose.campaigns).toBe('CAMPAIGNS');
|
|
66
|
-
expect(Purchasely.DataProcessingPurpose.personalization).toBe('PERSONALIZATION');
|
|
67
|
-
expect(Purchasely.DataProcessingPurpose.thirdPartyIntegrations).toBe('THIRD_PARTY_INTEGRATIONS');
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('PurchaseResult', () => {
|
|
72
|
-
it('should have correct purchase result values', () => {
|
|
73
|
-
expect(Purchasely.PurchaseResult.PURCHASED).toBe(0);
|
|
74
|
-
expect(Purchasely.PurchaseResult.CANCELLED).toBe(1);
|
|
75
|
-
expect(Purchasely.PurchaseResult.RESTORED).toBe(2);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('SubscriptionSource', () => {
|
|
80
|
-
it('should have correct subscription source values', () => {
|
|
81
|
-
expect(Purchasely.SubscriptionSource.appleAppStore).toBe(0);
|
|
82
|
-
expect(Purchasely.SubscriptionSource.googlePlayStore).toBe(1);
|
|
83
|
-
expect(Purchasely.SubscriptionSource.amazonAppstore).toBe(2);
|
|
84
|
-
expect(Purchasely.SubscriptionSource.huaweiAppGallery).toBe(3);
|
|
85
|
-
expect(Purchasely.SubscriptionSource.none).toBe(4);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe('PlanType', () => {
|
|
90
|
-
it('should have correct plan type values', () => {
|
|
91
|
-
expect(Purchasely.PlanType.consumable).toBe(0);
|
|
92
|
-
expect(Purchasely.PlanType.nonConsumable).toBe(1);
|
|
93
|
-
expect(Purchasely.PlanType.autoRenewingSubscription).toBe(2);
|
|
94
|
-
expect(Purchasely.PlanType.nonRenewingSubscription).toBe(3);
|
|
95
|
-
expect(Purchasely.PlanType.unknown).toBe(4);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe('RunningMode', () => {
|
|
100
|
-
it('should expose the Purchasely 6.0 running modes by name', () => {
|
|
101
|
-
expect(Purchasely.RunningMode.observer).toBe('observer');
|
|
102
|
-
expect(Purchasely.RunningMode.full).toBe('full');
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('PresentationAction', () => {
|
|
107
|
-
it('should have correct presentation action values', () => {
|
|
108
|
-
expect(Purchasely.PresentationAction.close).toBe('close');
|
|
109
|
-
expect(Purchasely.PresentationAction.close_all).toBe('close_all');
|
|
110
|
-
expect(Purchasely.PresentationAction.login).toBe('login');
|
|
111
|
-
expect(Purchasely.PresentationAction.navigate).toBe('navigate');
|
|
112
|
-
expect(Purchasely.PresentationAction.purchase).toBe('purchase');
|
|
113
|
-
expect(Purchasely.PresentationAction.restore).toBe('restore');
|
|
114
|
-
expect(Purchasely.PresentationAction.open_presentation).toBe('open_presentation');
|
|
115
|
-
expect(Purchasely.PresentationAction.open_placement).toBe('open_placement');
|
|
116
|
-
expect(Purchasely.PresentationAction.promo_code).toBe('promo_code');
|
|
117
|
-
expect(Purchasely.PresentationAction.web_checkout).toBe('web_checkout');
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe('InterceptResult', () => {
|
|
122
|
-
it('should have correct intercept result values', () => {
|
|
123
|
-
expect(Purchasely.InterceptResult.success).toBe('success');
|
|
124
|
-
expect(Purchasely.InterceptResult.failed).toBe('failed');
|
|
125
|
-
expect(Purchasely.InterceptResult.notHandled).toBe('notHandled');
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe('PresentationType', () => {
|
|
130
|
-
it('should have correct presentation type values', () => {
|
|
131
|
-
expect(Purchasely.PresentationType.normal).toBe(0);
|
|
132
|
-
expect(Purchasely.PresentationType.fallback).toBe(1);
|
|
133
|
-
expect(Purchasely.PresentationType.deactivated).toBe(2);
|
|
134
|
-
expect(Purchasely.PresentationType.client).toBe(3);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
describe('CloseReason', () => {
|
|
139
|
-
it('should have correct close reason values', () => {
|
|
140
|
-
expect(Purchasely.CloseReason.button).toBe('button');
|
|
141
|
-
expect(Purchasely.CloseReason.backSystem).toBe('back_system');
|
|
142
|
-
expect(Purchasely.CloseReason.programmatic).toBe('programmatic');
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
describe('TransitionType', () => {
|
|
147
|
-
it('should have correct transition type values', () => {
|
|
148
|
-
expect(Purchasely.TransitionType.fullScreen).toBe('fullScreen');
|
|
149
|
-
expect(Purchasely.TransitionType.modal).toBe('modal');
|
|
150
|
-
expect(Purchasely.TransitionType.drawer).toBe('drawer');
|
|
151
|
-
expect(Purchasely.TransitionType.popin).toBe('popin');
|
|
152
|
-
expect(Purchasely.TransitionType.push).toBe('push');
|
|
153
|
-
expect(Purchasely.TransitionType.inlinePaywall).toBe('inlinePaywall');
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
describe('DimensionType', () => {
|
|
158
|
-
it('should have correct dimension type values', () => {
|
|
159
|
-
expect(Purchasely.DimensionType.pixel).toBe('pixel');
|
|
160
|
-
expect(Purchasely.DimensionType.percentage).toBe('percentage');
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
describe('Store', () => {
|
|
165
|
-
it('should have correct store values', () => {
|
|
166
|
-
expect(Purchasely.Store.google).toBe('Google');
|
|
167
|
-
expect(Purchasely.Store.huawei).toBe('Huawei');
|
|
168
|
-
expect(Purchasely.Store.amazon).toBe('Amazon');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('StorekitVersion', () => {
|
|
173
|
-
it('should have correct storekit version values', () => {
|
|
174
|
-
expect(Purchasely.StorekitVersion.storeKit1).toBe('storeKit1');
|
|
175
|
-
expect(Purchasely.StorekitVersion.storeKit2).toBe('storeKit2');
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
describe('ThemeMode', () => {
|
|
180
|
-
it('should have correct theme mode values', () => {
|
|
181
|
-
expect(Purchasely.ThemeMode.light).toBe(0);
|
|
182
|
-
expect(Purchasely.ThemeMode.dark).toBe(1);
|
|
183
|
-
expect(Purchasely.ThemeMode.system).toBe(2);
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
describe('UserAttributeAction', () => {
|
|
188
|
-
it('should have correct user attribute action values', () => {
|
|
189
|
-
expect(Purchasely.UserAttributeAction.ADD).toBe('add');
|
|
190
|
-
expect(Purchasely.UserAttributeAction.REMOVE).toBe('remove');
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe('start', () => {
|
|
196
|
-
it('should call exec with a single options object (with sdkVersion appended)', () => {
|
|
197
|
-
const success = jest.fn();
|
|
198
|
-
const error = jest.fn();
|
|
199
|
-
|
|
200
|
-
Purchasely.start(
|
|
201
|
-
{
|
|
202
|
-
apiKey: 'API_KEY',
|
|
203
|
-
stores: [Purchasely.Store.google],
|
|
204
|
-
storeKit1: false,
|
|
205
|
-
appUserId: 'user123',
|
|
206
|
-
logLevel: Purchasely.LogLevel.INFO,
|
|
207
|
-
runningMode: Purchasely.RunningMode.full
|
|
208
|
-
},
|
|
209
|
-
success,
|
|
210
|
-
error
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
214
|
-
success,
|
|
215
|
-
error,
|
|
216
|
-
'Purchasely',
|
|
217
|
-
'start',
|
|
218
|
-
[
|
|
219
|
-
{
|
|
220
|
-
apiKey: 'API_KEY',
|
|
221
|
-
stores: ['Google'],
|
|
222
|
-
storeKit1: false,
|
|
223
|
-
appUserId: 'user123',
|
|
224
|
-
logLevel: 1,
|
|
225
|
-
runningMode: 'full',
|
|
226
|
-
sdkVersion: '5.6.2'
|
|
227
|
-
}
|
|
228
|
-
]
|
|
229
|
-
);
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
describe('addEventsListener', () => {
|
|
234
|
-
it('should call exec with correct parameters', () => {
|
|
235
|
-
const success = jest.fn();
|
|
236
|
-
const error = jest.fn();
|
|
237
|
-
|
|
238
|
-
Purchasely.addEventsListener(success, error);
|
|
239
|
-
|
|
240
|
-
expect(mockExec).toHaveBeenCalledWith(success, error, 'Purchasely', 'addEventsListener', []);
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
describe('addUserAttributeListener', () => {
|
|
245
|
-
it('should call exec with correct parameters', () => {
|
|
246
|
-
const success = jest.fn();
|
|
247
|
-
const error = jest.fn();
|
|
248
|
-
|
|
249
|
-
Purchasely.addUserAttributeListener(success, error);
|
|
250
|
-
|
|
251
|
-
expect(mockExec).toHaveBeenCalledWith(success, error, 'Purchasely', 'addUserAttributeListener', []);
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
describe('removeEventsListener', () => {
|
|
256
|
-
it('should call exec with correct parameters', () => {
|
|
257
|
-
Purchasely.removeEventsListener();
|
|
258
|
-
|
|
259
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
260
|
-
expect.any(Function),
|
|
261
|
-
expect.any(Function),
|
|
262
|
-
'Purchasely',
|
|
263
|
-
'removeEventsListener',
|
|
264
|
-
[]
|
|
265
|
-
);
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
describe('removeUserAttributeListener', () => {
|
|
270
|
-
it('should call exec with correct parameters', () => {
|
|
271
|
-
Purchasely.removeUserAttributeListener();
|
|
272
|
-
|
|
273
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
274
|
-
expect.any(Function),
|
|
275
|
-
expect.any(Function),
|
|
276
|
-
'Purchasely',
|
|
277
|
-
'removeUserAttributeListener',
|
|
278
|
-
[]
|
|
279
|
-
);
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
describe('getAnonymousUserId', () => {
|
|
284
|
-
it('should call exec with correct parameters', () => {
|
|
285
|
-
const success = jest.fn();
|
|
286
|
-
const error = jest.fn();
|
|
287
|
-
|
|
288
|
-
Purchasely.getAnonymousUserId(success, error);
|
|
289
|
-
|
|
290
|
-
expect(mockExec).toHaveBeenCalledWith(success, error, 'Purchasely', 'getAnonymousUserId', []);
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
describe('userLogin', () => {
|
|
295
|
-
it('should call exec with correct parameters', () => {
|
|
296
|
-
const success = jest.fn();
|
|
297
|
-
|
|
298
|
-
Purchasely.userLogin('user123', success);
|
|
299
|
-
|
|
300
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
301
|
-
success,
|
|
302
|
-
expect.any(Function),
|
|
303
|
-
'Purchasely',
|
|
304
|
-
'userLogin',
|
|
305
|
-
['user123']
|
|
306
|
-
);
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
describe('userLogout', () => {
|
|
311
|
-
it('should call exec with correct parameters', () => {
|
|
312
|
-
Purchasely.userLogout();
|
|
313
|
-
|
|
314
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
315
|
-
expect.any(Function),
|
|
316
|
-
expect.any(Function),
|
|
317
|
-
'Purchasely',
|
|
318
|
-
'userLogout',
|
|
319
|
-
[]
|
|
320
|
-
);
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
describe('setLogLevel', () => {
|
|
325
|
-
it('should call exec with correct parameters', () => {
|
|
326
|
-
Purchasely.setLogLevel(Purchasely.LogLevel.DEBUG);
|
|
327
|
-
|
|
328
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
329
|
-
expect.any(Function),
|
|
330
|
-
expect.any(Function),
|
|
331
|
-
'Purchasely',
|
|
332
|
-
'setLogLevel',
|
|
333
|
-
[0]
|
|
334
|
-
);
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
describe('setAttribute', () => {
|
|
339
|
-
it('should call exec with correct parameters', () => {
|
|
340
|
-
Purchasely.setAttribute(Purchasely.Attribute.FIREBASE_APP_INSTANCE_ID, 'firebase123');
|
|
341
|
-
|
|
342
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
343
|
-
expect.any(Function),
|
|
344
|
-
expect.any(Function),
|
|
345
|
-
'Purchasely',
|
|
346
|
-
'setAttribute',
|
|
347
|
-
[0, 'firebase123']
|
|
348
|
-
);
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
describe('allowDeeplink', () => {
|
|
353
|
-
it('should call exec with correct parameters', () => {
|
|
354
|
-
Purchasely.allowDeeplink(true);
|
|
355
|
-
|
|
356
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
357
|
-
expect.any(Function),
|
|
358
|
-
expect.any(Function),
|
|
359
|
-
'Purchasely',
|
|
360
|
-
'allowDeeplink',
|
|
361
|
-
[true]
|
|
362
|
-
);
|
|
363
|
-
});
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
describe('allowCampaigns', () => {
|
|
367
|
-
it('should call exec with correct parameters', () => {
|
|
368
|
-
Purchasely.allowCampaigns(false);
|
|
369
|
-
|
|
370
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
371
|
-
expect.any(Function),
|
|
372
|
-
expect.any(Function),
|
|
373
|
-
'Purchasely',
|
|
374
|
-
'allowCampaigns',
|
|
375
|
-
[false]
|
|
376
|
-
);
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
describe('setDefaultPresentationDismissHandler', () => {
|
|
381
|
-
it('should call exec with correct parameters', () => {
|
|
382
|
-
const success = jest.fn();
|
|
383
|
-
const error = jest.fn();
|
|
384
|
-
|
|
385
|
-
Purchasely.setDefaultPresentationDismissHandler(success, error);
|
|
386
|
-
|
|
387
|
-
expect(mockExec).toHaveBeenCalledWith(success, error, 'Purchasely', 'setDefaultPresentationDismissHandler', []);
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
describe('synchronize', () => {
|
|
392
|
-
it('should call exec with the provided callbacks', () => {
|
|
393
|
-
const success = jest.fn();
|
|
394
|
-
const error = jest.fn();
|
|
395
|
-
|
|
396
|
-
Purchasely.synchronize(success, error);
|
|
397
|
-
|
|
398
|
-
expect(mockExec).toHaveBeenCalledWith(success, error, 'Purchasely', 'synchronize', []);
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it('should default callbacks when none provided', () => {
|
|
402
|
-
Purchasely.synchronize();
|
|
403
|
-
|
|
404
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
405
|
-
expect.any(Function),
|
|
406
|
-
expect.any(Function),
|
|
407
|
-
'Purchasely',
|
|
408
|
-
'synchronize',
|
|
409
|
-
[]
|
|
410
|
-
);
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
describe('presentPresentationWithIdentifier', () => {
|
|
415
|
-
it('should pass a display-mode string as a transition object', () => {
|
|
416
|
-
const success = jest.fn();
|
|
417
|
-
const error = jest.fn();
|
|
418
|
-
|
|
419
|
-
Purchasely.presentPresentationWithIdentifier('presentation1', 'content1', Purchasely.TransitionType.drawer, success, error);
|
|
420
|
-
|
|
421
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
422
|
-
expect.any(Function),
|
|
423
|
-
error,
|
|
424
|
-
'Purchasely',
|
|
425
|
-
'presentPresentationWithIdentifier',
|
|
426
|
-
['presentation1', 'content1', { type: 'drawer' }]
|
|
427
|
-
);
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
it('should normalize a legacy isFullscreen=true to fullScreen', () => {
|
|
431
|
-
const success = jest.fn();
|
|
432
|
-
const error = jest.fn();
|
|
433
|
-
|
|
434
|
-
Purchasely.presentPresentationWithIdentifier('presentation1', 'content1', true, success, error);
|
|
435
|
-
|
|
436
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
437
|
-
expect.any(Function),
|
|
438
|
-
error,
|
|
439
|
-
'Purchasely',
|
|
440
|
-
'presentPresentationWithIdentifier',
|
|
441
|
-
['presentation1', 'content1', { type: 'fullScreen' }]
|
|
442
|
-
);
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
it('should pass a full transition object (dimensions/dismissible) through unchanged', () => {
|
|
446
|
-
const success = jest.fn();
|
|
447
|
-
const error = jest.fn();
|
|
448
|
-
const transition = { type: 'drawer', dismissible: false, height: { type: 'percentage', value: 0.8 } };
|
|
449
|
-
|
|
450
|
-
Purchasely.presentPresentationWithIdentifier('presentation1', null, transition, success, error);
|
|
451
|
-
|
|
452
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
453
|
-
expect.any(Function),
|
|
454
|
-
error,
|
|
455
|
-
'Purchasely',
|
|
456
|
-
'presentPresentationWithIdentifier',
|
|
457
|
-
['presentation1', null, transition]
|
|
458
|
-
);
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
describe('presentPresentationForPlacement', () => {
|
|
463
|
-
it('should normalize a legacy isFullscreen=false to modal', () => {
|
|
464
|
-
const success = jest.fn();
|
|
465
|
-
const error = jest.fn();
|
|
466
|
-
|
|
467
|
-
Purchasely.presentPresentationForPlacement('placement1', 'content1', false, success, error);
|
|
468
|
-
|
|
469
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
470
|
-
expect.any(Function),
|
|
471
|
-
error,
|
|
472
|
-
'Purchasely',
|
|
473
|
-
'presentPresentationForPlacement',
|
|
474
|
-
['placement1', 'content1', { type: 'modal' }]
|
|
475
|
-
);
|
|
476
|
-
});
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
describe('presentPresentationForDefault', () => {
|
|
480
|
-
it('should present the default presentation with a transition object', () => {
|
|
481
|
-
const success = jest.fn();
|
|
482
|
-
const error = jest.fn();
|
|
483
|
-
|
|
484
|
-
Purchasely.presentPresentationForDefault('content1', Purchasely.TransitionType.fullScreen, success, error);
|
|
485
|
-
|
|
486
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
487
|
-
expect.any(Function),
|
|
488
|
-
error,
|
|
489
|
-
'Purchasely',
|
|
490
|
-
'presentPresentationForDefault',
|
|
491
|
-
['content1', { type: 'fullScreen' }]
|
|
492
|
-
);
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
describe('presentation lifecycle callbacks', () => {
|
|
497
|
-
it('routes presented/closeRequested envelopes to callbacks and the final outcome to success', () => {
|
|
498
|
-
const success = jest.fn();
|
|
499
|
-
const onPresented = jest.fn();
|
|
500
|
-
const onCloseRequested = jest.fn();
|
|
501
|
-
|
|
502
|
-
Purchasely.presentPresentationForPlacement('p', null, 'fullScreen', success, jest.fn(), { onPresented, onCloseRequested });
|
|
503
|
-
|
|
504
|
-
const dispatch = mockExec.mock.calls[0][0];
|
|
505
|
-
dispatch({ event: 'presented', presentation: { screenId: 's' } });
|
|
506
|
-
dispatch({ event: 'closeRequested' });
|
|
507
|
-
dispatch({ result: 1, purchaseResult: 'cancelled', closeReason: 'button' });
|
|
508
|
-
|
|
509
|
-
expect(onPresented).toHaveBeenCalledWith({ screenId: 's' }, null);
|
|
510
|
-
expect(onCloseRequested).toHaveBeenCalledTimes(1);
|
|
511
|
-
expect(success).toHaveBeenCalledWith({ result: 1, purchaseResult: 'cancelled', closeReason: 'button' });
|
|
512
|
-
});
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
describe('removeDefaultPresentationDismissHandler', () => {
|
|
516
|
-
it('should call exec with correct parameters', () => {
|
|
517
|
-
Purchasely.removeDefaultPresentationDismissHandler();
|
|
518
|
-
|
|
519
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
520
|
-
expect.any(Function),
|
|
521
|
-
expect.any(Function),
|
|
522
|
-
'Purchasely',
|
|
523
|
-
'removeDefaultPresentationDismissHandler',
|
|
524
|
-
[]
|
|
525
|
-
);
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
describe('fetchPresentation', () => {
|
|
530
|
-
it('should call exec with correct parameters', () => {
|
|
531
|
-
const success = jest.fn();
|
|
532
|
-
const error = jest.fn();
|
|
533
|
-
|
|
534
|
-
Purchasely.fetchPresentation('presentation1', 'content1', success, error);
|
|
535
|
-
|
|
536
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
537
|
-
success,
|
|
538
|
-
error,
|
|
539
|
-
'Purchasely',
|
|
540
|
-
'fetchPresentation',
|
|
541
|
-
[null, 'presentation1', 'content1']
|
|
542
|
-
);
|
|
543
|
-
});
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
describe('fetchPresentationForPlacement', () => {
|
|
547
|
-
it('should call exec with correct parameters', () => {
|
|
548
|
-
const success = jest.fn();
|
|
549
|
-
const error = jest.fn();
|
|
550
|
-
|
|
551
|
-
Purchasely.fetchPresentationForPlacement('placement1', 'content1', success, error);
|
|
552
|
-
|
|
553
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
554
|
-
success,
|
|
555
|
-
error,
|
|
556
|
-
'Purchasely',
|
|
557
|
-
'fetchPresentation',
|
|
558
|
-
['placement1', null, 'content1']
|
|
559
|
-
);
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
describe('fetchPresentationForDefault', () => {
|
|
564
|
-
it('should call exec with both ids null', () => {
|
|
565
|
-
const success = jest.fn();
|
|
566
|
-
const error = jest.fn();
|
|
567
|
-
|
|
568
|
-
Purchasely.fetchPresentationForDefault('content1', success, error);
|
|
569
|
-
|
|
570
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
571
|
-
success,
|
|
572
|
-
error,
|
|
573
|
-
'Purchasely',
|
|
574
|
-
'fetchPresentation',
|
|
575
|
-
[null, null, 'content1']
|
|
576
|
-
);
|
|
577
|
-
});
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
describe('presentPresentation', () => {
|
|
581
|
-
it('should call exec with a transition object', () => {
|
|
582
|
-
const success = jest.fn();
|
|
583
|
-
const error = jest.fn();
|
|
584
|
-
const presentation = { id: 'test' };
|
|
585
|
-
|
|
586
|
-
Purchasely.presentPresentation(presentation, Purchasely.TransitionType.fullScreen, '#FFFFFF', success, error);
|
|
587
|
-
|
|
588
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
589
|
-
expect.any(Function),
|
|
590
|
-
error,
|
|
591
|
-
'Purchasely',
|
|
592
|
-
'presentPresentation',
|
|
593
|
-
[presentation, { type: 'fullScreen' }, '#FFFFFF']
|
|
594
|
-
);
|
|
595
|
-
});
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
describe('purchaseWithPlanVendorId', () => {
|
|
599
|
-
it('should call exec with correct parameters', () => {
|
|
600
|
-
const success = jest.fn();
|
|
601
|
-
const error = jest.fn();
|
|
602
|
-
|
|
603
|
-
Purchasely.purchaseWithPlanVendorId('plan1', 'offer1', 'content1', success, error);
|
|
604
|
-
|
|
605
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
606
|
-
success,
|
|
607
|
-
error,
|
|
608
|
-
'Purchasely',
|
|
609
|
-
'purchaseWithPlanVendorId',
|
|
610
|
-
['plan1', 'offer1', 'content1']
|
|
611
|
-
);
|
|
612
|
-
});
|
|
613
|
-
});
|
|
614
|
-
|
|
615
|
-
describe('restoreAllProducts', () => {
|
|
616
|
-
it('should call exec with correct parameters', () => {
|
|
617
|
-
const success = jest.fn();
|
|
618
|
-
const error = jest.fn();
|
|
619
|
-
|
|
620
|
-
Purchasely.restoreAllProducts(success, error);
|
|
621
|
-
|
|
622
|
-
expect(mockExec).toHaveBeenCalledWith(success, error, 'Purchasely', 'restoreAllProducts', []);
|
|
623
|
-
});
|
|
624
|
-
});
|
|
625
|
-
|
|
626
|
-
describe('silentRestoreAllProducts', () => {
|
|
627
|
-
it('should call exec with correct parameters', () => {
|
|
628
|
-
const success = jest.fn();
|
|
629
|
-
const error = jest.fn();
|
|
630
|
-
|
|
631
|
-
Purchasely.silentRestoreAllProducts(success, error);
|
|
632
|
-
|
|
633
|
-
expect(mockExec).toHaveBeenCalledWith(success, error, 'Purchasely', 'silentRestoreAllProducts', []);
|
|
634
|
-
});
|
|
635
|
-
});
|
|
636
|
-
|
|
637
|
-
describe('purchasedSubscription', () => {
|
|
638
|
-
it('should call exec with correct parameters', () => {
|
|
639
|
-
const success = jest.fn();
|
|
640
|
-
const error = jest.fn();
|
|
641
|
-
|
|
642
|
-
Purchasely.purchasedSubscription(success, error);
|
|
643
|
-
|
|
644
|
-
expect(mockExec).toHaveBeenCalledWith(success, error, 'Purchasely', 'purchasedSubscription', []);
|
|
645
|
-
});
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
describe('handleDeeplink', () => {
|
|
649
|
-
it('should call exec with correct parameters', () => {
|
|
650
|
-
const success = jest.fn();
|
|
651
|
-
const error = jest.fn();
|
|
652
|
-
|
|
653
|
-
Purchasely.handleDeeplink('https://example.com/deeplink', success, error);
|
|
654
|
-
|
|
655
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
656
|
-
success,
|
|
657
|
-
error,
|
|
658
|
-
'Purchasely',
|
|
659
|
-
'handleDeeplink',
|
|
660
|
-
['https://example.com/deeplink']
|
|
661
|
-
);
|
|
662
|
-
});
|
|
663
|
-
});
|
|
664
|
-
|
|
665
|
-
describe('allProducts', () => {
|
|
666
|
-
it('should call exec with correct parameters', () => {
|
|
667
|
-
const success = jest.fn();
|
|
668
|
-
const error = jest.fn();
|
|
669
|
-
|
|
670
|
-
Purchasely.allProducts(success, error);
|
|
671
|
-
|
|
672
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
673
|
-
success,
|
|
674
|
-
expect.any(Function),
|
|
675
|
-
'Purchasely',
|
|
676
|
-
'allProducts',
|
|
677
|
-
[]
|
|
678
|
-
);
|
|
679
|
-
});
|
|
680
|
-
});
|
|
681
|
-
|
|
682
|
-
describe('planWithIdentifier', () => {
|
|
683
|
-
it('should call exec with correct parameters', () => {
|
|
684
|
-
const success = jest.fn();
|
|
685
|
-
|
|
686
|
-
Purchasely.planWithIdentifier('plan1', success);
|
|
687
|
-
|
|
688
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
689
|
-
success,
|
|
690
|
-
expect.any(Function),
|
|
691
|
-
'Purchasely',
|
|
692
|
-
'planWithIdentifier',
|
|
693
|
-
['plan1']
|
|
694
|
-
);
|
|
695
|
-
});
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
describe('productWithIdentifier', () => {
|
|
699
|
-
it('should call exec with correct parameters', () => {
|
|
700
|
-
const success = jest.fn();
|
|
701
|
-
|
|
702
|
-
Purchasely.productWithIdentifier('product1', success);
|
|
703
|
-
|
|
704
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
705
|
-
success,
|
|
706
|
-
expect.any(Function),
|
|
707
|
-
'Purchasely',
|
|
708
|
-
'productWithIdentifier',
|
|
709
|
-
['product1']
|
|
710
|
-
);
|
|
711
|
-
});
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
// Flush pending microtasks (the interceptor result is reported through a Promise chain).
|
|
715
|
-
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
|
|
716
|
-
|
|
717
|
-
// Returns the native success callback exec() was given for a registerActionInterceptor(kind).
|
|
718
|
-
const nativeInterceptorFor = (kind) => {
|
|
719
|
-
const call = mockExec.mock.calls.find(
|
|
720
|
-
(c) => c[3] === 'registerActionInterceptor' && c[4][0] === kind
|
|
721
|
-
);
|
|
722
|
-
return call && call[0];
|
|
723
|
-
};
|
|
724
|
-
|
|
725
|
-
describe('interceptAction (v6 per-action)', () => {
|
|
726
|
-
it('registers a native interceptor for the given kind', () => {
|
|
727
|
-
Purchasely.interceptAction('purchase', jest.fn());
|
|
728
|
-
|
|
729
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
730
|
-
expect.any(Function),
|
|
731
|
-
expect.any(Function),
|
|
732
|
-
'Purchasely',
|
|
733
|
-
'registerActionInterceptor',
|
|
734
|
-
['purchase']
|
|
735
|
-
);
|
|
736
|
-
});
|
|
737
|
-
|
|
738
|
-
it('invokes the handler with (info, parameters) and reports its result', async () => {
|
|
739
|
-
const handler = jest.fn().mockReturnValue(Purchasely.InterceptResult.success);
|
|
740
|
-
Purchasely.interceptAction('purchase', handler);
|
|
741
|
-
const nativeSuccess = nativeInterceptorFor('purchase');
|
|
742
|
-
mockExec.mockClear();
|
|
743
|
-
|
|
744
|
-
const event = {
|
|
745
|
-
action: 'purchase',
|
|
746
|
-
callbackId: 'purchase#1',
|
|
747
|
-
info: { contentId: 'c1' },
|
|
748
|
-
parameters: { plan: 'p1' },
|
|
749
|
-
};
|
|
750
|
-
nativeSuccess(event);
|
|
751
|
-
await flush();
|
|
752
|
-
|
|
753
|
-
expect(handler).toHaveBeenCalledWith(event.info, event.parameters);
|
|
754
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
755
|
-
expect.any(Function),
|
|
756
|
-
expect.any(Function),
|
|
757
|
-
'Purchasely',
|
|
758
|
-
'completeActionInterceptor',
|
|
759
|
-
['purchase#1', 'success']
|
|
760
|
-
);
|
|
761
|
-
});
|
|
762
|
-
|
|
763
|
-
it('ignores events whose action does not match the registered kind', async () => {
|
|
764
|
-
const handler = jest.fn();
|
|
765
|
-
Purchasely.interceptAction('restore', handler);
|
|
766
|
-
const nativeSuccess = nativeInterceptorFor('restore');
|
|
767
|
-
|
|
768
|
-
nativeSuccess({ action: 'purchase', callbackId: 'purchase#2' });
|
|
769
|
-
await flush();
|
|
770
|
-
|
|
771
|
-
expect(handler).not.toHaveBeenCalled();
|
|
772
|
-
});
|
|
773
|
-
|
|
774
|
-
it('reports failed when the handler throws', async () => {
|
|
775
|
-
Purchasely.interceptAction('purchase', () => { throw new Error('boom'); });
|
|
776
|
-
const nativeSuccess = nativeInterceptorFor('purchase');
|
|
777
|
-
mockExec.mockClear();
|
|
778
|
-
|
|
779
|
-
nativeSuccess({ action: 'purchase', callbackId: 'purchase#3' });
|
|
780
|
-
await flush();
|
|
781
|
-
|
|
782
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
783
|
-
expect.any(Function),
|
|
784
|
-
expect.any(Function),
|
|
785
|
-
'Purchasely',
|
|
786
|
-
'completeActionInterceptor',
|
|
787
|
-
['purchase#3', 'failed']
|
|
788
|
-
);
|
|
789
|
-
});
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
describe('removeActionInterceptor', () => {
|
|
793
|
-
it('unregisters a single kind', () => {
|
|
794
|
-
Purchasely.removeActionInterceptor('purchase');
|
|
795
|
-
|
|
796
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
797
|
-
expect.any(Function),
|
|
798
|
-
expect.any(Function),
|
|
799
|
-
'Purchasely',
|
|
800
|
-
'unregisterActionInterceptor',
|
|
801
|
-
['purchase']
|
|
802
|
-
);
|
|
803
|
-
});
|
|
804
|
-
});
|
|
805
|
-
|
|
806
|
-
describe('removeAllActionInterceptors', () => {
|
|
807
|
-
it('unregisters every registered kind', () => {
|
|
808
|
-
Purchasely.interceptAction('purchase', jest.fn());
|
|
809
|
-
Purchasely.interceptAction('restore', jest.fn());
|
|
810
|
-
mockExec.mockClear();
|
|
811
|
-
|
|
812
|
-
Purchasely.removeAllActionInterceptors();
|
|
813
|
-
|
|
814
|
-
const unregistered = mockExec.mock.calls
|
|
815
|
-
.filter((c) => c[3] === 'unregisterActionInterceptor')
|
|
816
|
-
.map((c) => c[4][0]);
|
|
817
|
-
expect(unregistered).toEqual(expect.arrayContaining(['purchase', 'restore']));
|
|
818
|
-
});
|
|
819
|
-
});
|
|
820
|
-
|
|
821
|
-
describe('userDidConsumeSubscriptionContent', () => {
|
|
822
|
-
it('should call exec with correct parameters', () => {
|
|
823
|
-
Purchasely.userDidConsumeSubscriptionContent();
|
|
824
|
-
|
|
825
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
826
|
-
expect.any(Function),
|
|
827
|
-
expect.any(Function),
|
|
828
|
-
'Purchasely',
|
|
829
|
-
'userDidConsumeSubscriptionContent',
|
|
830
|
-
[]
|
|
831
|
-
);
|
|
832
|
-
});
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
describe('userSubscriptions', () => {
|
|
836
|
-
it('should call exec with correct parameters', () => {
|
|
837
|
-
const success = jest.fn();
|
|
838
|
-
const error = jest.fn();
|
|
839
|
-
|
|
840
|
-
Purchasely.userSubscriptions(success, error);
|
|
841
|
-
|
|
842
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
843
|
-
success,
|
|
844
|
-
expect.any(Function),
|
|
845
|
-
'Purchasely',
|
|
846
|
-
'userSubscriptions',
|
|
847
|
-
[]
|
|
848
|
-
);
|
|
849
|
-
});
|
|
850
|
-
});
|
|
851
|
-
|
|
852
|
-
describe('userSubscriptionsHistory', () => {
|
|
853
|
-
it('should call exec with correct parameters', () => {
|
|
854
|
-
const success = jest.fn();
|
|
855
|
-
const error = jest.fn();
|
|
856
|
-
|
|
857
|
-
Purchasely.userSubscriptionsHistory(success, error);
|
|
858
|
-
|
|
859
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
860
|
-
success,
|
|
861
|
-
expect.any(Function),
|
|
862
|
-
'Purchasely',
|
|
863
|
-
'userSubscriptionsHistory',
|
|
864
|
-
[]
|
|
865
|
-
);
|
|
866
|
-
});
|
|
867
|
-
});
|
|
868
|
-
|
|
869
|
-
describe('setLanguage', () => {
|
|
870
|
-
it('should call exec with correct parameters', () => {
|
|
871
|
-
Purchasely.setLanguage('fr');
|
|
872
|
-
|
|
873
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
874
|
-
expect.any(Function),
|
|
875
|
-
expect.any(Function),
|
|
876
|
-
'Purchasely',
|
|
877
|
-
'setLanguage',
|
|
878
|
-
['fr']
|
|
879
|
-
);
|
|
880
|
-
});
|
|
881
|
-
});
|
|
882
|
-
|
|
883
|
-
describe('closePresentation', () => {
|
|
884
|
-
it('should call exec with correct parameters', () => {
|
|
885
|
-
Purchasely.closePresentation();
|
|
886
|
-
|
|
887
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
888
|
-
expect.any(Function),
|
|
889
|
-
expect.any(Function),
|
|
890
|
-
'Purchasely',
|
|
891
|
-
'closePresentation',
|
|
892
|
-
[]
|
|
893
|
-
);
|
|
894
|
-
});
|
|
895
|
-
});
|
|
896
|
-
|
|
897
|
-
describe('backPresentation', () => {
|
|
898
|
-
it('should call exec with correct parameters', () => {
|
|
899
|
-
Purchasely.backPresentation();
|
|
900
|
-
|
|
901
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
902
|
-
expect.any(Function),
|
|
903
|
-
expect.any(Function),
|
|
904
|
-
'Purchasely',
|
|
905
|
-
'backPresentation',
|
|
906
|
-
[]
|
|
907
|
-
);
|
|
908
|
-
});
|
|
909
|
-
});
|
|
910
|
-
|
|
911
|
-
describe('User Attributes', () => {
|
|
912
|
-
describe('setUserAttributeWithString', () => {
|
|
913
|
-
it('should call exec with correct parameters', () => {
|
|
914
|
-
Purchasely.setUserAttributeWithString('name', 'John', 'ESSENTIAL');
|
|
915
|
-
|
|
916
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
917
|
-
expect.any(Function),
|
|
918
|
-
expect.any(Function),
|
|
919
|
-
'Purchasely',
|
|
920
|
-
'setUserAttributeWithString',
|
|
921
|
-
['name', 'John', 'ESSENTIAL']
|
|
922
|
-
);
|
|
923
|
-
});
|
|
924
|
-
});
|
|
925
|
-
|
|
926
|
-
describe('setUserAttributeWithBoolean', () => {
|
|
927
|
-
it('should call exec with correct parameters', () => {
|
|
928
|
-
Purchasely.setUserAttributeWithBoolean('isPremium', true, 'OPTIONAL');
|
|
929
|
-
|
|
930
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
931
|
-
expect.any(Function),
|
|
932
|
-
expect.any(Function),
|
|
933
|
-
'Purchasely',
|
|
934
|
-
'setUserAttributeWithBoolean',
|
|
935
|
-
['isPremium', true, 'OPTIONAL']
|
|
936
|
-
);
|
|
937
|
-
});
|
|
938
|
-
});
|
|
939
|
-
|
|
940
|
-
describe('setUserAttributeWithInt', () => {
|
|
941
|
-
it('should call exec with correct parameters', () => {
|
|
942
|
-
Purchasely.setUserAttributeWithInt('age', 25, 'ESSENTIAL');
|
|
943
|
-
|
|
944
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
945
|
-
expect.any(Function),
|
|
946
|
-
expect.any(Function),
|
|
947
|
-
'Purchasely',
|
|
948
|
-
'setUserAttributeWithInt',
|
|
949
|
-
['age', 25, 'ESSENTIAL']
|
|
950
|
-
);
|
|
951
|
-
});
|
|
952
|
-
});
|
|
953
|
-
|
|
954
|
-
describe('setUserAttributeWithDouble', () => {
|
|
955
|
-
it('should call exec with correct parameters', () => {
|
|
956
|
-
Purchasely.setUserAttributeWithDouble('balance', 99.99, 'ESSENTIAL');
|
|
957
|
-
|
|
958
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
959
|
-
expect.any(Function),
|
|
960
|
-
expect.any(Function),
|
|
961
|
-
'Purchasely',
|
|
962
|
-
'setUserAttributeWithDouble',
|
|
963
|
-
['balance', 99.99, 'ESSENTIAL']
|
|
964
|
-
);
|
|
965
|
-
});
|
|
966
|
-
});
|
|
967
|
-
|
|
968
|
-
describe('setUserAttributeWithDate', () => {
|
|
969
|
-
it('should call exec with correct parameters', () => {
|
|
970
|
-
Purchasely.setUserAttributeWithDate('birthdate', '1990-01-01', 'ESSENTIAL');
|
|
971
|
-
|
|
972
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
973
|
-
expect.any(Function),
|
|
974
|
-
expect.any(Function),
|
|
975
|
-
'Purchasely',
|
|
976
|
-
'setUserAttributeWithDate',
|
|
977
|
-
['birthdate', '1990-01-01', 'ESSENTIAL']
|
|
978
|
-
);
|
|
979
|
-
});
|
|
980
|
-
});
|
|
981
|
-
|
|
982
|
-
describe('setUserAttributeWithStringArray', () => {
|
|
983
|
-
it('should call exec with correct parameters', () => {
|
|
984
|
-
Purchasely.setUserAttributeWithStringArray('tags', ['a', 'b'], 'ESSENTIAL');
|
|
985
|
-
|
|
986
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
987
|
-
expect.any(Function),
|
|
988
|
-
expect.any(Function),
|
|
989
|
-
'Purchasely',
|
|
990
|
-
'setUserAttributeWithStringArray',
|
|
991
|
-
['tags', ['a', 'b'], 'ESSENTIAL']
|
|
992
|
-
);
|
|
993
|
-
});
|
|
994
|
-
});
|
|
995
|
-
|
|
996
|
-
describe('setUserAttributeWithIntArray', () => {
|
|
997
|
-
it('should call exec with correct parameters', () => {
|
|
998
|
-
Purchasely.setUserAttributeWithIntArray('scores', [1, 2, 3], 'ESSENTIAL');
|
|
999
|
-
|
|
1000
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
1001
|
-
expect.any(Function),
|
|
1002
|
-
expect.any(Function),
|
|
1003
|
-
'Purchasely',
|
|
1004
|
-
'setUserAttributeWithIntArray',
|
|
1005
|
-
['scores', [1, 2, 3], 'ESSENTIAL']
|
|
1006
|
-
);
|
|
1007
|
-
});
|
|
1008
|
-
});
|
|
1009
|
-
|
|
1010
|
-
describe('setUserAttributeWithDoubleArray', () => {
|
|
1011
|
-
it('should call exec with correct parameters', () => {
|
|
1012
|
-
Purchasely.setUserAttributeWithDoubleArray('prices', [1.1, 2.2], 'ESSENTIAL');
|
|
1013
|
-
|
|
1014
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
1015
|
-
expect.any(Function),
|
|
1016
|
-
expect.any(Function),
|
|
1017
|
-
'Purchasely',
|
|
1018
|
-
'setUserAttributeWithDoubleArray',
|
|
1019
|
-
['prices', [1.1, 2.2], 'ESSENTIAL']
|
|
1020
|
-
);
|
|
1021
|
-
});
|
|
1022
|
-
});
|
|
1023
|
-
|
|
1024
|
-
describe('setUserAttributeWithBooleanArray', () => {
|
|
1025
|
-
it('should call exec with correct parameters', () => {
|
|
1026
|
-
Purchasely.setUserAttributeWithBooleanArray('flags', [true, false], 'ESSENTIAL');
|
|
1027
|
-
|
|
1028
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
1029
|
-
expect.any(Function),
|
|
1030
|
-
expect.any(Function),
|
|
1031
|
-
'Purchasely',
|
|
1032
|
-
'setUserAttributeWithBooleanArray',
|
|
1033
|
-
['flags', [true, false], 'ESSENTIAL']
|
|
1034
|
-
);
|
|
1035
|
-
});
|
|
1036
|
-
});
|
|
1037
|
-
|
|
1038
|
-
describe('userAttribute', () => {
|
|
1039
|
-
it('should call exec with correct parameters', () => {
|
|
1040
|
-
const success = jest.fn();
|
|
1041
|
-
const error = jest.fn();
|
|
1042
|
-
|
|
1043
|
-
Purchasely.userAttribute('name', success, error);
|
|
1044
|
-
|
|
1045
|
-
expect(mockExec).toHaveBeenCalledWith(success, error, 'Purchasely', 'userAttribute', ['name']);
|
|
1046
|
-
});
|
|
1047
|
-
});
|
|
1048
|
-
|
|
1049
|
-
describe('clearUserAttribute', () => {
|
|
1050
|
-
it('should call exec with correct parameters', () => {
|
|
1051
|
-
Purchasely.clearUserAttribute('name');
|
|
1052
|
-
|
|
1053
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
1054
|
-
expect.any(Function),
|
|
1055
|
-
expect.any(Function),
|
|
1056
|
-
'Purchasely',
|
|
1057
|
-
'clearUserAttribute',
|
|
1058
|
-
['name']
|
|
1059
|
-
);
|
|
1060
|
-
});
|
|
1061
|
-
});
|
|
1062
|
-
|
|
1063
|
-
describe('clearUserAttributes', () => {
|
|
1064
|
-
it('should call exec with correct parameters', () => {
|
|
1065
|
-
Purchasely.clearUserAttributes();
|
|
1066
|
-
|
|
1067
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
1068
|
-
expect.any(Function),
|
|
1069
|
-
expect.any(Function),
|
|
1070
|
-
'Purchasely',
|
|
1071
|
-
'clearUserAttributes',
|
|
1072
|
-
[]
|
|
1073
|
-
);
|
|
1074
|
-
});
|
|
1075
|
-
});
|
|
1076
|
-
|
|
1077
|
-
describe('clearBuiltInAttributes', () => {
|
|
1078
|
-
it('should call exec with correct parameters', () => {
|
|
1079
|
-
Purchasely.clearBuiltInAttributes();
|
|
1080
|
-
|
|
1081
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
1082
|
-
expect.any(Function),
|
|
1083
|
-
expect.any(Function),
|
|
1084
|
-
'Purchasely',
|
|
1085
|
-
'clearBuiltInAttributes',
|
|
1086
|
-
[]
|
|
1087
|
-
);
|
|
1088
|
-
});
|
|
1089
|
-
});
|
|
1090
|
-
});
|
|
1091
|
-
|
|
1092
|
-
describe('isEligibleForIntroOffer', () => {
|
|
1093
|
-
it('should call exec with correct parameters', () => {
|
|
1094
|
-
const success = jest.fn();
|
|
1095
|
-
const error = jest.fn();
|
|
1096
|
-
|
|
1097
|
-
Purchasely.isEligibleForIntroOffer('plan1', success, error);
|
|
1098
|
-
|
|
1099
|
-
expect(mockExec).toHaveBeenCalledWith(success, error, 'Purchasely', 'isEligibleForIntroOffer', ['plan1']);
|
|
1100
|
-
});
|
|
1101
|
-
});
|
|
1102
|
-
|
|
1103
|
-
describe('signPromotionalOffer', () => {
|
|
1104
|
-
it('should call exec with correct parameters', () => {
|
|
1105
|
-
const success = jest.fn();
|
|
1106
|
-
const error = jest.fn();
|
|
1107
|
-
|
|
1108
|
-
Purchasely.signPromotionalOffer('product1', 'offer1', success, error);
|
|
1109
|
-
|
|
1110
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
1111
|
-
success,
|
|
1112
|
-
error,
|
|
1113
|
-
'Purchasely',
|
|
1114
|
-
'signPromotionalOffer',
|
|
1115
|
-
['product1', 'offer1']
|
|
1116
|
-
);
|
|
1117
|
-
});
|
|
1118
|
-
});
|
|
1119
|
-
|
|
1120
|
-
describe('setThemeMode', () => {
|
|
1121
|
-
it('should call exec with correct parameters', () => {
|
|
1122
|
-
Purchasely.setThemeMode(Purchasely.ThemeMode.dark);
|
|
1123
|
-
|
|
1124
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
1125
|
-
expect.any(Function),
|
|
1126
|
-
expect.any(Function),
|
|
1127
|
-
'Purchasely',
|
|
1128
|
-
'setThemeMode',
|
|
1129
|
-
[1]
|
|
1130
|
-
);
|
|
1131
|
-
});
|
|
1132
|
-
});
|
|
1133
|
-
|
|
1134
|
-
describe('revokeDataProcessingConsent', () => {
|
|
1135
|
-
it('should call exec with correct parameters', () => {
|
|
1136
|
-
Purchasely.revokeDataProcessingConsent(['ANALYTICS', 'CAMPAIGNS']);
|
|
1137
|
-
|
|
1138
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
1139
|
-
expect.any(Function),
|
|
1140
|
-
expect.any(Function),
|
|
1141
|
-
'Purchasely',
|
|
1142
|
-
'revokeDataProcessingConsent',
|
|
1143
|
-
[['ANALYTICS', 'CAMPAIGNS']]
|
|
1144
|
-
);
|
|
1145
|
-
});
|
|
1146
|
-
});
|
|
1147
|
-
|
|
1148
|
-
describe('setDebugMode', () => {
|
|
1149
|
-
it('should call exec with correct parameters', () => {
|
|
1150
|
-
Purchasely.setDebugMode(true);
|
|
1151
|
-
|
|
1152
|
-
expect(mockExec).toHaveBeenCalledWith(
|
|
1153
|
-
expect.any(Function),
|
|
1154
|
-
expect.any(Function),
|
|
1155
|
-
'Purchasely',
|
|
1156
|
-
'setDebugMode',
|
|
1157
|
-
[true]
|
|
1158
|
-
);
|
|
1159
|
-
});
|
|
1160
|
-
});
|
|
1161
|
-
});
|