@snowplow/react-native-tracker 2.1.2 → 4.0.2-dev.0

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.
Files changed (232) hide show
  1. package/LICENSE +29 -203
  2. package/README.md +59 -143
  3. package/dist/index.cjs.d.ts +499 -0
  4. package/dist/index.cjs.js +2656 -0
  5. package/dist/index.cjs.js.map +1 -0
  6. package/dist/index.cjs.min.d.ts +499 -0
  7. package/dist/index.cjs.min.js +63 -0
  8. package/dist/index.cjs.min.js.map +1 -0
  9. package/dist/index.module.d.ts +499 -0
  10. package/dist/index.module.js +250 -0
  11. package/dist/index.module.js.map +1 -0
  12. package/package.json +48 -158
  13. package/.editorconfig +0 -15
  14. package/.eslintignore +0 -6
  15. package/.gitattributes +0 -3
  16. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -29
  17. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  18. package/.github/actions/setup/action.yml +0 -28
  19. package/.github/workflows/build.yml +0 -155
  20. package/.github/workflows/deploy.yml +0 -97
  21. package/.github/workflows/e2e-android.yml +0 -121
  22. package/.github/workflows/e2e-ios.yml +0 -95
  23. package/.github/workflows/snyk.yml +0 -21
  24. package/.gitignore +0 -70
  25. package/.npmignore +0 -60
  26. package/.nvmrc +0 -1
  27. package/.watchmanconfig +0 -1
  28. package/.yarnrc +0 -3
  29. package/CHANGELOG +0 -184
  30. package/CONTRIBUTING.md +0 -80
  31. package/android/build.gradle +0 -110
  32. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  33. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  34. package/android/gradle.properties +0 -5
  35. package/android/gradlew +0 -234
  36. package/android/gradlew.bat +0 -89
  37. package/android/src/main/AndroidManifest.xml +0 -3
  38. package/android/src/main/AndroidManifestNew.xml +0 -2
  39. package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerModule.kt +0 -744
  40. package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerPackage.kt +0 -17
  41. package/android/src/main/java/com/snowplow/reactnativetracker/util/ConfigUtil.kt +0 -274
  42. package/android/src/main/java/com/snowplow/reactnativetracker/util/EventUtil.kt +0 -233
  43. package/android/src/main/java/com/snowplow/reactnativetracker/util/TrackerVersion.kt +0 -5
  44. package/babel.config.js +0 -3
  45. package/example/.watchmanconfig +0 -1
  46. package/example/Gemfile +0 -6
  47. package/example/android/app/build.gradle +0 -129
  48. package/example/android/app/debug.keystore +0 -0
  49. package/example/android/app/proguard-rules.pro +0 -10
  50. package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTest.java +0 -36
  51. package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTestAppJUnitRunner.java +0 -21
  52. package/example/android/app/src/debug/AndroidManifest.xml +0 -13
  53. package/example/android/app/src/debug/java/com/reactnativetrackerexample/ReactNativeFlipper.java +0 -75
  54. package/example/android/app/src/main/AndroidManifest.xml +0 -26
  55. package/example/android/app/src/main/java/com/reactnativetrackerexample/MainActivity.java +0 -32
  56. package/example/android/app/src/main/java/com/reactnativetrackerexample/MainApplication.java +0 -62
  57. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -36
  58. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  59. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  60. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  61. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  62. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  63. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  64. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  65. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  66. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  67. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  68. package/example/android/app/src/main/res/values/strings.xml +0 -3
  69. package/example/android/app/src/main/res/values/styles.xml +0 -9
  70. package/example/android/app/src/release/java/com/reactnativetrackerexample/ReactNativeFlipper.java +0 -20
  71. package/example/android/build.gradle +0 -31
  72. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  73. package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  74. package/example/android/gradle.properties +0 -44
  75. package/example/android/gradlew +0 -244
  76. package/example/android/gradlew.bat +0 -92
  77. package/example/android/settings.gradle +0 -4
  78. package/example/app.json +0 -4
  79. package/example/babel.config.js +0 -17
  80. package/example/detox.config.js +0 -92
  81. package/example/e2e/config.json +0 -10
  82. package/example/e2e/emitEvents.e2e.detox.js +0 -95
  83. package/example/e2e/environment.js +0 -23
  84. package/example/e2e/helpers/microCommands.js +0 -140
  85. package/example/e2e/helpers/microHelpers.js +0 -333
  86. package/example/e2e/helpers/microHelpers.test.js +0 -295
  87. package/example/e2e/helpers/schemas.js +0 -49
  88. package/example/e2e/jest.config.js +0 -16
  89. package/example/e2e/setup.js +0 -4
  90. package/example/e2e/testEvents.micro.test.js +0 -287
  91. package/example/index.js +0 -5
  92. package/example/ios/.xcode.env +0 -11
  93. package/example/ios/Podfile +0 -62
  94. package/example/ios/Podfile.lock +0 -730
  95. package/example/ios/ReactNativeTrackerExample/AppDelegate.h +0 -6
  96. package/example/ios/ReactNativeTrackerExample/AppDelegate.mm +0 -26
  97. package/example/ios/ReactNativeTrackerExample/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
  98. package/example/ios/ReactNativeTrackerExample/Images.xcassets/Contents.json +0 -6
  99. package/example/ios/ReactNativeTrackerExample/Info.plist +0 -55
  100. package/example/ios/ReactNativeTrackerExample/LaunchScreen.storyboard +0 -47
  101. package/example/ios/ReactNativeTrackerExample/PrivacyInfo.xcprivacy +0 -37
  102. package/example/ios/ReactNativeTrackerExample/main.m +0 -10
  103. package/example/ios/ReactNativeTrackerExample-Bridging-Header.h +0 -3
  104. package/example/ios/ReactNativeTrackerExample.xcodeproj/project.pbxproj +0 -739
  105. package/example/ios/ReactNativeTrackerExample.xcodeproj/xcshareddata/xcschemes/ReactNativeTrackerExample.xcscheme +0 -88
  106. package/example/ios/ReactNativeTrackerExample.xcworkspace/contents.xcworkspacedata +0 -10
  107. package/example/ios/ReactNativeTrackerExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  108. package/example/ios/ReactNativeTrackerExampleTests/Info.plist +0 -24
  109. package/example/ios/ReactNativeTrackerExampleTests/ReactNativeTrackerExampleTests.m +0 -66
  110. package/example/metro.config.js +0 -45
  111. package/example/package.json +0 -54
  112. package/example/react-native.config.js +0 -10
  113. package/example/src/App.js +0 -566
  114. package/example/tsconfig.json +0 -5
  115. package/example/yarn.lock +0 -7703
  116. package/ios/ReactNativeTracker-Bridging-Header.h +0 -2
  117. package/ios/ReactNativeTracker.mm +0 -171
  118. package/ios/ReactNativeTracker.swift +0 -822
  119. package/ios/ReactNativeTracker.xcodeproj/project.pbxproj +0 -301
  120. package/ios/Util/ConfigUtils.swift +0 -209
  121. package/ios/Util/TrackerVersion.swift +0 -3
  122. package/ios/Util/Utilities.swift +0 -37
  123. package/lefthook.yml +0 -11
  124. package/lib/commonjs/api.js +0 -490
  125. package/lib/commonjs/api.js.map +0 -1
  126. package/lib/commonjs/configurations.js +0 -196
  127. package/lib/commonjs/configurations.js.map +0 -1
  128. package/lib/commonjs/constants.js +0 -77
  129. package/lib/commonjs/constants.js.map +0 -1
  130. package/lib/commonjs/events.js +0 -277
  131. package/lib/commonjs/events.js.map +0 -1
  132. package/lib/commonjs/index.js +0 -132
  133. package/lib/commonjs/index.js.map +0 -1
  134. package/lib/commonjs/jsCore.js +0 -427
  135. package/lib/commonjs/jsCore.js.map +0 -1
  136. package/lib/commonjs/native.js +0 -16
  137. package/lib/commonjs/native.js.map +0 -1
  138. package/lib/commonjs/subject.js +0 -235
  139. package/lib/commonjs/subject.js.map +0 -1
  140. package/lib/commonjs/tracker.js +0 -248
  141. package/lib/commonjs/tracker.js.map +0 -1
  142. package/lib/commonjs/types.js +0 -2
  143. package/lib/commonjs/types.js.map +0 -1
  144. package/lib/commonjs/utils.js +0 -72
  145. package/lib/commonjs/utils.js.map +0 -1
  146. package/lib/commonjs/webViewInterface.js +0 -66
  147. package/lib/commonjs/webViewInterface.js.map +0 -1
  148. package/lib/module/api.js +0 -452
  149. package/lib/module/api.js.map +0 -1
  150. package/lib/module/configurations.js +0 -184
  151. package/lib/module/configurations.js.map +0 -1
  152. package/lib/module/constants.js +0 -72
  153. package/lib/module/constants.js.map +0 -1
  154. package/lib/module/events.js +0 -259
  155. package/lib/module/events.js.map +0 -1
  156. package/lib/module/index.js +0 -120
  157. package/lib/module/index.js.map +0 -1
  158. package/lib/module/jsCore.js +0 -424
  159. package/lib/module/jsCore.js.map +0 -1
  160. package/lib/module/native.js +0 -12
  161. package/lib/module/native.js.map +0 -1
  162. package/lib/module/subject.js +0 -222
  163. package/lib/module/subject.js.map +0 -1
  164. package/lib/module/tracker.js +0 -234
  165. package/lib/module/tracker.js.map +0 -1
  166. package/lib/module/types.js +0 -2
  167. package/lib/module/types.js.map +0 -1
  168. package/lib/module/utils.js +0 -66
  169. package/lib/module/utils.js.map +0 -1
  170. package/lib/module/webViewInterface.js +0 -62
  171. package/lib/module/webViewInterface.js.map +0 -1
  172. package/lib/typescript/__tests__/api.test.d.ts +0 -2
  173. package/lib/typescript/__tests__/api.test.d.ts.map +0 -1
  174. package/lib/typescript/__tests__/configurations.test.d.ts +0 -2
  175. package/lib/typescript/__tests__/configurations.test.d.ts.map +0 -1
  176. package/lib/typescript/__tests__/events.test.d.ts +0 -2
  177. package/lib/typescript/__tests__/events.test.d.ts.map +0 -1
  178. package/lib/typescript/__tests__/index.test.d.ts +0 -2
  179. package/lib/typescript/__tests__/index.test.d.ts.map +0 -1
  180. package/lib/typescript/__tests__/jsCore.test.d.ts +0 -2
  181. package/lib/typescript/__tests__/jsCore.test.d.ts.map +0 -1
  182. package/lib/typescript/__tests__/utils.test.d.ts +0 -2
  183. package/lib/typescript/__tests__/utils.test.d.ts.map +0 -1
  184. package/lib/typescript/api.d.ts +0 -240
  185. package/lib/typescript/api.d.ts.map +0 -1
  186. package/lib/typescript/configurations.d.ts +0 -73
  187. package/lib/typescript/configurations.d.ts.map +0 -1
  188. package/lib/typescript/constants.d.ts +0 -64
  189. package/lib/typescript/constants.d.ts.map +0 -1
  190. package/lib/typescript/events.d.ts +0 -115
  191. package/lib/typescript/events.d.ts.map +0 -1
  192. package/lib/typescript/index.d.ts +0 -27
  193. package/lib/typescript/index.d.ts.map +0 -1
  194. package/lib/typescript/jsCore.d.ts +0 -152
  195. package/lib/typescript/jsCore.d.ts.map +0 -1
  196. package/lib/typescript/native.d.ts +0 -4
  197. package/lib/typescript/native.d.ts.map +0 -1
  198. package/lib/typescript/subject.d.ts +0 -91
  199. package/lib/typescript/subject.d.ts.map +0 -1
  200. package/lib/typescript/tracker.d.ts +0 -111
  201. package/lib/typescript/tracker.d.ts.map +0 -1
  202. package/lib/typescript/types.d.ts +0 -981
  203. package/lib/typescript/types.d.ts.map +0 -1
  204. package/lib/typescript/utils.d.ts +0 -35
  205. package/lib/typescript/utils.d.ts.map +0 -1
  206. package/lib/typescript/webViewInterface.d.ts +0 -15
  207. package/lib/typescript/webViewInterface.d.ts.map +0 -1
  208. package/scripts/bootstrap.js +0 -29
  209. package/snowplow-react-native-tracker.podspec +0 -42
  210. package/src/__mocks__/react-native.js +0 -7
  211. package/src/__tests__/api.test.ts +0 -21
  212. package/src/__tests__/configurations.test.ts +0 -608
  213. package/src/__tests__/events.test.ts +0 -736
  214. package/src/__tests__/index.test.ts +0 -14
  215. package/src/__tests__/jsCore.test.ts +0 -199
  216. package/src/__tests__/utils.test.ts +0 -10
  217. package/src/api.ts +0 -556
  218. package/src/configurations.ts +0 -325
  219. package/src/constants.ts +0 -97
  220. package/src/events.ts +0 -355
  221. package/src/index.ts +0 -184
  222. package/src/jsCore.ts +0 -603
  223. package/src/native.ts +0 -21
  224. package/src/subject.ts +0 -302
  225. package/src/tracker.ts +0 -377
  226. package/src/types.ts +0 -1162
  227. package/src/utils.ts +0 -65
  228. package/src/webViewInterface.ts +0 -92
  229. package/tsconfig.build.json +0 -5
  230. package/tsconfig.json +0 -28
  231. package/turbo.json +0 -34
  232. package/yarn.lock +0 -9398
@@ -1,736 +0,0 @@
1
- import * as e from '../events';
2
- import { logMessages } from '../constants';
3
-
4
- describe('test isValidSD', () => {
5
- test('test invalid type', () => {
6
- const testSD = undefined as any;
7
- expect(e.isValidSD(testSD)).toBe(false);
8
- });
9
-
10
- test('test invalid - no keys', () => {
11
- const testSD = {} as any;
12
- expect(e.isValidSD(testSD)).toBe(false);
13
- });
14
-
15
- test('test invalid schema', () => {
16
- const testSD = {
17
- schema: null,
18
- data: { test: 'test' },
19
- } as any;
20
- expect(e.isValidSD(testSD)).toBe(false);
21
- });
22
-
23
- test('test invalid data', () => {
24
- const testSD = {
25
- schema: 'testSchema',
26
- data: undefined,
27
- } as any;
28
- expect(e.isValidSD(testSD)).toBe(false);
29
- });
30
-
31
- test('test valid', () => {
32
- const testSD = {
33
- schema: 'testSchema',
34
- data: {
35
- test: 'valid',
36
- },
37
- };
38
- expect(e.isValidSD(testSD)).toBe(true);
39
- });
40
- });
41
-
42
- describe('test validateContexts', () => {
43
- test('test invalid type', async () => {
44
- const testContexts = 'notArray' as any;
45
- await expect(e.validateContexts(testContexts)).rejects.toThrow(
46
- logMessages.context
47
- );
48
- });
49
-
50
- test('test invalid contexts', async () => {
51
- const testContexts = [
52
- { schema: 'test', data: { test: 'test' } },
53
- { schema: null, data: { test: 'invalid' } },
54
- ] as any;
55
- await expect(e.validateContexts(testContexts)).rejects.toThrow(
56
- logMessages.context
57
- );
58
- });
59
-
60
- test('test valid contexts - empty', async () => {
61
- const testContexts = [] as any;
62
- await expect(e.validateContexts(testContexts)).resolves.toBe(true);
63
- });
64
-
65
- test('test valid contexts', async () => {
66
- const testContexts = [
67
- { schema: 'test', data: { test: 'test' } },
68
- { schema: 'test', data: { test: 'valid' } },
69
- ];
70
- await expect(e.validateContexts(testContexts)).resolves.toBe(true);
71
- });
72
- });
73
-
74
- describe('test validateSelfDesc', () => {
75
- test('test invalid self-describing - wrong type', async () => {
76
- const testEv = undefined as any;
77
- await expect(e.validateSelfDesc(testEv)).rejects.toThrow(
78
- logMessages.selfDesc
79
- );
80
- });
81
-
82
- test('test invalid self-describing - empty object', async () => {
83
- const testEv = {} as any;
84
- await expect(e.validateSelfDesc(testEv)).rejects.toThrow(
85
- logMessages.selfDesc
86
- );
87
- });
88
-
89
- test('test valid self-describing', async () => {
90
- const testEv = { schema: 'test', data: { test: 'test' } };
91
- await expect(e.validateSelfDesc(testEv)).resolves.toBe(true);
92
- });
93
- });
94
-
95
- describe('test validateScreenView', () => {
96
- test('test invalid screen-view - wrong type', async () => {
97
- const testEv = null as any;
98
- await expect(e.validateScreenView(testEv)).rejects.toThrow(
99
- logMessages.evType
100
- );
101
- });
102
-
103
- test('test invalid screen-view - missing name', async () => {
104
- const testEv = { type: 'test' } as any;
105
- await expect(e.validateScreenView(testEv)).rejects.toThrow(
106
- logMessages.screenViewReq
107
- );
108
- });
109
-
110
- test('test invalid screen-view - wrong name', async () => {
111
- const testEv = { name: null } as any;
112
- await expect(e.validateScreenView(testEv)).rejects.toThrow(
113
- logMessages.screenViewReq
114
- );
115
- });
116
-
117
- test('test valid screen-view', async () => {
118
- const testEv = {
119
- name: 'test',
120
- type: 'test',
121
- previousName: 'preTest',
122
- transitionType: 'testing',
123
- };
124
- await expect(e.validateScreenView(testEv)).resolves.toBe(true);
125
- });
126
- });
127
-
128
- describe('test validateStructured', () => {
129
- test('test invalid structured - wrong type', async () => {
130
- const testEv = undefined as any;
131
- await expect(e.validateStructured(testEv)).rejects.toThrow(
132
- logMessages.evType
133
- );
134
- });
135
-
136
- test('test invalid structured - missing category', async () => {
137
- const testEv = { action: 'test' } as any;
138
- await expect(e.validateStructured(testEv)).rejects.toThrow(
139
- logMessages.structuredReq
140
- );
141
- });
142
-
143
- test('test invalid structured - missing action', async () => {
144
- const testEv = { category: 'test' } as any;
145
- await expect(e.validateStructured(testEv)).rejects.toThrow(
146
- logMessages.structuredReq
147
- );
148
- });
149
-
150
- test('test invalid structured - wrong category', async () => {
151
- const testEv = { category: null } as any;
152
- await expect(e.validateStructured(testEv)).rejects.toThrow(
153
- logMessages.structuredReq
154
- );
155
- });
156
-
157
- test('test invalid structured - wrong action', async () => {
158
- const testEv = { action: undefined } as any;
159
- await expect(e.validateStructured(testEv)).rejects.toThrow(
160
- logMessages.structuredReq
161
- );
162
- });
163
-
164
- test('test valid structured', async () => {
165
- const testEv = {
166
- category: 'test',
167
- action: 'test',
168
- label: 'test',
169
- property: 'test',
170
- value: 0,
171
- };
172
- await expect(e.validateStructured(testEv)).resolves.toBe(true);
173
- });
174
- });
175
-
176
- describe('test validatePageView', () => {
177
- test('test invalid page-view - wrong type', async () => {
178
- const testEv = 'pageView' as any;
179
- await expect(e.validatePageView(testEv)).rejects.toThrow(
180
- logMessages.evType
181
- );
182
- });
183
-
184
- test('test invalid page-view - missing pageUrl', async () => {
185
- const testEv = { pageTitle: 'test' } as any;
186
- await expect(e.validatePageView(testEv)).rejects.toThrow(
187
- logMessages.pageviewReq
188
- );
189
- });
190
-
191
- test('test invalid page-view - pageUrl set to null', async () => {
192
- const testEv = { pageUrl: null } as any;
193
- await expect(e.validatePageView(testEv)).rejects.toThrow(
194
- logMessages.pageviewReq
195
- );
196
- });
197
-
198
- test('test valid page-view', async () => {
199
- const testEv = {
200
- pageUrl: 'test.test',
201
- pageTitle: 'test',
202
- pageReferrer: 'tested',
203
- };
204
- await expect(e.validatePageView(testEv)).resolves.toBe(true);
205
- });
206
- });
207
-
208
- describe('test validateTiming', () => {
209
- test('test invalid timing - wrong type', async () => {
210
- const testEv = undefined as any;
211
- await expect(e.validateTiming(testEv)).rejects.toThrow(logMessages.evType);
212
- });
213
-
214
- test('test invalid timing - missing category', async () => {
215
- const testEv = {
216
- variable: 'test',
217
- timing: 0,
218
- } as any;
219
- await expect(e.validateTiming(testEv)).rejects.toThrow(
220
- logMessages.timingReq
221
- );
222
- });
223
-
224
- test('test invalid timing - missing variable', async () => {
225
- const testEv = {
226
- category: 'test',
227
- timing: 0,
228
- } as any;
229
- await expect(e.validateTiming(testEv)).rejects.toThrow(
230
- logMessages.timingReq
231
- );
232
- });
233
-
234
- test('test invalid timing - missing timing', async () => {
235
- const testEv = {
236
- category: 'testing',
237
- variable: 'test',
238
- } as any;
239
- await expect(e.validateTiming(testEv)).rejects.toThrow(
240
- logMessages.timingReq
241
- );
242
- });
243
-
244
- test('test invalid timing - wrong category', async () => {
245
- const testEv = {
246
- category: null,
247
- variable: 'test',
248
- timing: 0,
249
- } as any;
250
- await expect(e.validateTiming(testEv)).rejects.toThrow(
251
- logMessages.timingReq
252
- );
253
- });
254
-
255
- test('test invalid timing - wrong variable', async () => {
256
- const testEv = {
257
- category: 'test',
258
- variable: null,
259
- timing: 0,
260
- } as any;
261
- await expect(e.validateTiming(testEv)).rejects.toThrow(
262
- logMessages.timingReq
263
- );
264
- });
265
-
266
- test('test invalid timing - wrong timing', async () => {
267
- const testEv = {
268
- category: 'testing',
269
- variable: 'test',
270
- timing: 'invalid',
271
- } as any;
272
- await expect(e.validateTiming(testEv)).rejects.toThrow(
273
- logMessages.timingReq
274
- );
275
- });
276
-
277
- test('test valid timing', async () => {
278
- const testEv = {
279
- category: 'testing',
280
- variable: 'test',
281
- timing: 0,
282
- label: 'test',
283
- };
284
- await expect(e.validateTiming(testEv)).resolves.toBe(true);
285
- });
286
- });
287
-
288
- describe('test validateConsentGranted', () => {
289
- test('test invalid consentGranted - wrong type', async () => {
290
- const testEv = null as any;
291
- await expect(e.validateConsentGranted(testEv)).rejects.toThrow(
292
- logMessages.evType
293
- );
294
- });
295
-
296
- test('test invalid consentGranted - missing expiry', async () => {
297
- const testEv = {
298
- documentId: 'testId',
299
- version: '0.0.1',
300
- } as any;
301
- await expect(e.validateConsentGranted(testEv)).rejects.toThrow(
302
- logMessages.consentGReq
303
- );
304
- });
305
-
306
- test('test invalid consentGranted - missing documentId', async () => {
307
- const testEv = {
308
- expiry: '2022-01-01T00:00:00Z',
309
- version: '0.0.1',
310
- } as any;
311
- await expect(e.validateConsentGranted(testEv)).rejects.toThrow(
312
- logMessages.consentGReq
313
- );
314
- });
315
-
316
- test('test invalid consentGranted - missing version', async () => {
317
- const testEv = {
318
- expiry: '2022-01-01T00:00:00Z',
319
- documentId: 'testId',
320
- } as any;
321
- await expect(e.validateConsentGranted(testEv)).rejects.toThrow(
322
- logMessages.consentGReq
323
- );
324
- });
325
-
326
- test('test invalid consentGranted - wrong expiry', async () => {
327
- const testEv = {
328
- expiry: 0,
329
- documentId: 'testId',
330
- version: '0.0.1',
331
- } as any;
332
- await expect(e.validateConsentGranted(testEv)).rejects.toThrow(
333
- logMessages.consentGReq
334
- );
335
- });
336
-
337
- test('test invalid consentGranted - wrong documentId', async () => {
338
- const testEv = {
339
- expiry: '2022-01-01T00:00:00Z',
340
- documentId: 0,
341
- version: '0.0.1',
342
- } as any;
343
- await expect(e.validateConsentGranted(testEv)).rejects.toThrow(
344
- logMessages.consentGReq
345
- );
346
- });
347
-
348
- test('test invalid consentGranted - wrong version', async () => {
349
- const testEv = {
350
- expiry: '2022-01-01T00:00:00Z',
351
- documentId: 'testId',
352
- version: undefined,
353
- } as any;
354
- await expect(e.validateConsentGranted(testEv)).rejects.toThrow(
355
- logMessages.consentGReq
356
- );
357
- });
358
-
359
- test('test valid consentGranted', async () => {
360
- const testEv = {
361
- expiry: '2022-01-01T00:00:00Z',
362
- documentId: 'testId',
363
- version: '0.0.1',
364
- name: 'testName',
365
- documentDescription: 'testDescription',
366
- };
367
- await expect(e.validateConsentGranted(testEv)).resolves.toBe(true);
368
- });
369
- });
370
-
371
- describe('test validateConsentWithdrawn', () => {
372
- test('test invalid consentWithdrawn - wrong type', async () => {
373
- const testEv = null as any;
374
- await expect(e.validateConsentWithdrawn(testEv)).rejects.toThrow(
375
- logMessages.evType
376
- );
377
- });
378
-
379
- test('test invalid consentWithdrawn - missing all', async () => {
380
- const testEv = {
381
- documentId: 'testId',
382
- version: '0.0.1',
383
- } as any;
384
- await expect(e.validateConsentWithdrawn(testEv)).rejects.toThrow(
385
- logMessages.consentWReq
386
- );
387
- });
388
-
389
- test('test invalid consentWithdrawn - missing documentId', async () => {
390
- const testEv = {
391
- all: false,
392
- version: '0.0.1',
393
- } as any;
394
- await expect(e.validateConsentWithdrawn(testEv)).rejects.toThrow(
395
- logMessages.consentWReq
396
- );
397
- });
398
-
399
- test('test invalid consentWithdrawn - missing version', async () => {
400
- const testEv = {
401
- all: true,
402
- documentId: 'testId',
403
- } as any;
404
- await expect(e.validateConsentWithdrawn(testEv)).rejects.toThrow(
405
- logMessages.consentWReq
406
- );
407
- });
408
-
409
- test('test invalid consentWithdrawn - wrong all', async () => {
410
- const testEv = {
411
- all: 'wrong',
412
- documentId: 'testId',
413
- version: '0.0.1',
414
- } as any;
415
- await expect(e.validateConsentWithdrawn(testEv)).rejects.toThrow(
416
- logMessages.consentWReq
417
- );
418
- });
419
-
420
- test('test invalid consentWithdrawn - wrong documentId', async () => {
421
- const testEv = {
422
- all: true,
423
- documentId: null,
424
- version: '0.0.1',
425
- } as any;
426
- await expect(e.validateConsentWithdrawn(testEv)).rejects.toThrow(
427
- logMessages.consentWReq
428
- );
429
- });
430
-
431
- test('test invalid consentWithdrawn - wrong version', async () => {
432
- const testEv = {
433
- all: true,
434
- documentId: 'testId',
435
- version: 0,
436
- } as any;
437
- await expect(e.validateConsentWithdrawn(testEv)).rejects.toThrow(
438
- logMessages.consentWReq
439
- );
440
- });
441
-
442
- test('test valid consentWithdrawn', async () => {
443
- const testEv = {
444
- all: true,
445
- documentId: 'testId',
446
- version: '0.0.1',
447
- name: 'testName',
448
- documentDescription: 'testDescription',
449
- };
450
- await expect(e.validateConsentWithdrawn(testEv)).resolves.toBe(true);
451
- });
452
- });
453
-
454
- describe('test validateDeepLinkReceived', () => {
455
- test('test invalid deepLinkReceived - wrong type', async () => {
456
- const testEv = null as any;
457
- await expect(e.validateDeepLinkReceived(testEv)).rejects.toThrow(
458
- logMessages.evType
459
- );
460
- });
461
-
462
- test('test invalid deepLinkReceived - missing url', async () => {
463
- const testEv = {} as any;
464
- await expect(e.validateDeepLinkReceived(testEv)).rejects.toThrow(
465
- logMessages.deepLinkReq
466
- );
467
- });
468
-
469
- test('test invalid deepLinkReceived - invalid url', async () => {
470
- const testEv = {
471
- url: true,
472
- } as any;
473
- await expect(e.validateDeepLinkReceived(testEv)).rejects.toThrow(
474
- logMessages.deepLinkReq
475
- );
476
- });
477
-
478
- test('test valid deepLinkReceived', async () => {
479
- const testEv = {
480
- url: 'https://example.com/to',
481
- referrer: 'https://example.com/from',
482
- };
483
- await expect(e.validateDeepLinkReceived(testEv)).resolves.toBe(true);
484
- });
485
- });
486
-
487
- describe('test validateMessageNotification', () => {
488
- test('test invalid messageNotification - wrong type', async () => {
489
- const testEv = null as any;
490
- await expect(e.validateMessageNotification(testEv)).rejects.toThrow(
491
- logMessages.evType
492
- );
493
- });
494
-
495
- test('test invalid messageNotification - missing properties', async () => {
496
- const testEv = {} as any;
497
- await expect(e.validateMessageNotification(testEv)).rejects.toThrow(
498
- logMessages.messageNotificationReq
499
- );
500
- });
501
-
502
- test('test invalid messageNotification - invalid trigger', async () => {
503
- const testEv = {
504
- title: 'x',
505
- body: 'y',
506
- trigger: 'z',
507
- } as any;
508
- await expect(e.validateMessageNotification(testEv)).rejects.toThrow(
509
- logMessages.messageNotificationReq
510
- );
511
- });
512
-
513
- test('test valid messageNotification', async () => {
514
- const testEv = {
515
- title: 'x',
516
- body: 'y',
517
- trigger: 'push',
518
- } as any;
519
- await expect(e.validateMessageNotification(testEv)).resolves.toBe(true);
520
- });
521
- });
522
-
523
- describe('test isValidEcomItem', () => {
524
- test('invalid - wrong type', () => {
525
- const testItem = 'invalid' as any;
526
- expect(e.isValidEcomItem(testItem)).toBe(false);
527
- });
528
- test('invalid - missing sku', () => {
529
- const testItem = {
530
- price: 0.1,
531
- quantity: 1,
532
- } as any;
533
- expect(e.isValidEcomItem(testItem)).toBe(false);
534
- });
535
- test('invalid - missing price', () => {
536
- const testItem = {
537
- sku: '123',
538
- quantity: 1,
539
- } as any;
540
- expect(e.isValidEcomItem(testItem)).toBe(false);
541
- });
542
- test('invalid - missing quantity', () => {
543
- const testItem = {
544
- sku: '123',
545
- price: 0.1,
546
- } as any;
547
- expect(e.isValidEcomItem(testItem)).toBe(false);
548
- });
549
- test('invalid - wrong sku', () => {
550
- const testItem = {
551
- sku: 123,
552
- price: 0.1,
553
- quantity: 1,
554
- } as any;
555
- expect(e.isValidEcomItem(testItem)).toBe(false);
556
- });
557
- test('invalid - wrong price', () => {
558
- const testItem = {
559
- sku: '123',
560
- price: '0.1',
561
- quantity: 1,
562
- } as any;
563
- expect(e.isValidEcomItem(testItem)).toBe(false);
564
- });
565
- test('invalid - wrong quantity', () => {
566
- const testItem = {
567
- sku: '123',
568
- price: 0.1,
569
- quantity: '1',
570
- } as any;
571
- expect(e.isValidEcomItem(testItem)).toBe(false);
572
- });
573
- test('valid', () => {
574
- const testItem = {
575
- sku: '123',
576
- price: 0.1,
577
- quantity: 1,
578
- };
579
- expect(e.isValidEcomItem(testItem)).toBe(true);
580
- });
581
- });
582
-
583
- describe('test validItemsArg', () => {
584
- test('invalid - not an array', () => {
585
- const testArg = undefined as any;
586
- expect(e.validItemsArg(testArg)).toBe(false);
587
- });
588
-
589
- test('invalid', () => {
590
- const testArg = [
591
- {
592
- sku: '123',
593
- price: 0.1,
594
- quantity: 1,
595
- },
596
- {
597
- sku: null,
598
- price: 0.1,
599
- quantity: 1,
600
- },
601
- ] as any;
602
- expect(e.validItemsArg(testArg)).toBe(false);
603
- });
604
-
605
- test('valid - empty', () => {
606
- const testArg = [] as any;
607
- expect(e.validItemsArg(testArg)).toBe(true);
608
- });
609
-
610
- test('valid', () => {
611
- const testArg = [
612
- {
613
- sku: '123',
614
- price: 0.1,
615
- quantity: 1,
616
- },
617
- ];
618
- expect(e.validItemsArg(testArg)).toBe(true);
619
- });
620
- });
621
-
622
- describe('test validateEcommerceTransaction', () => {
623
- test('invalid - wrong type', async () => {
624
- const testEcom = null as any;
625
- await expect(e.validateEcommerceTransaction(testEcom)).rejects.toThrow(
626
- logMessages.evType
627
- );
628
- });
629
-
630
- test('invalid - missing orderId', async () => {
631
- const testEcom = {
632
- totalValue: 0.1,
633
- items: [
634
- {
635
- sku: '123',
636
- price: 0.1,
637
- quantity: 1,
638
- },
639
- ],
640
- } as any;
641
- await expect(e.validateEcommerceTransaction(testEcom)).rejects.toThrow(
642
- logMessages.ecomReq
643
- );
644
- });
645
-
646
- test('invalid - missing totalValue', async () => {
647
- const testEcom = {
648
- orderId: '123',
649
- items: [
650
- {
651
- sku: '123',
652
- price: 0.1,
653
- quantity: 1,
654
- },
655
- ],
656
- } as any;
657
- await expect(e.validateEcommerceTransaction(testEcom)).rejects.toThrow(
658
- logMessages.ecomReq
659
- );
660
- });
661
-
662
- test('invalid - missing items', async () => {
663
- const testEcom = {
664
- orderId: '123',
665
- totalValue: 0.1,
666
- } as any;
667
- await expect(e.validateEcommerceTransaction(testEcom)).rejects.toThrow(
668
- logMessages.ecomReq
669
- );
670
- });
671
-
672
- test('invalid - wrong orderId', async () => {
673
- const testEcom = {
674
- orderId: 123,
675
- totalValue: 0.1,
676
- items: [
677
- {
678
- sku: '123',
679
- price: 0.1,
680
- quantity: 1,
681
- },
682
- ],
683
- } as any;
684
- await expect(e.validateEcommerceTransaction(testEcom)).rejects.toThrow(
685
- logMessages.ecomReq
686
- );
687
- });
688
-
689
- test('invalid - wrong totalValue', async () => {
690
- const testEcom = {
691
- orderId: '123',
692
- totalValue: '0.1',
693
- items: [
694
- {
695
- sku: '123',
696
- price: 0.1,
697
- quantity: 1,
698
- },
699
- ],
700
- } as any;
701
- await expect(e.validateEcommerceTransaction(testEcom)).rejects.toThrow(
702
- logMessages.ecomReq
703
- );
704
- });
705
-
706
- test('invalid - wrong items', async () => {
707
- const testEcom = {
708
- orderId: '123',
709
- totalValue: 0.1,
710
- items: [
711
- {
712
- sku: '123',
713
- quantity: 1,
714
- },
715
- ],
716
- } as any;
717
- await expect(e.validateEcommerceTransaction(testEcom)).rejects.toThrow(
718
- logMessages.ecomReq
719
- );
720
- });
721
-
722
- test('valid', async () => {
723
- const testEcom = {
724
- orderId: '123',
725
- totalValue: 0.1,
726
- items: [
727
- {
728
- sku: '123',
729
- price: 0.1,
730
- quantity: 1,
731
- },
732
- ],
733
- };
734
- await expect(e.validateEcommerceTransaction(testEcom)).resolves.toBe(true);
735
- });
736
- });