@applicaster/zapp-react-native-utils 12.0.0-rc.6 → 12.0.0-rc.60

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 (82) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +16 -8
  2. package/analyticsUtils/AnalyticsEvents/index.ts +6 -0
  3. package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
  4. package/analyticsUtils/__tests__/analyticsManager.test.js +75 -73
  5. package/analyticsUtils/events.ts +6 -0
  6. package/analyticsUtils/helpers/hooks.ts +1 -1
  7. package/analyticsUtils/index.tsx +6 -0
  8. package/appUtils/HooksManager/index.js +3 -1
  9. package/appUtils/focusManager/treeDataStructure/Utils/index.js +12 -3
  10. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
  11. package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
  12. package/appUtils/keyCodes/keys.web.js +1 -0
  13. package/appUtils/orientationHelper.ts +1 -1
  14. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +53 -0
  15. package/appUtils/playerManager/conts.ts +5 -0
  16. package/appUtils/playerManager/player.ts +47 -4
  17. package/appUtils/playerManager/playerFactory.ts +15 -1
  18. package/appUtils/playerManager/playerNative.ts +35 -0
  19. package/appUtils/playerManager/usePlayerState.tsx +13 -1
  20. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +50 -0
  21. package/cellUtils/__tests__/cellUtils.test.ts +48 -0
  22. package/cellUtils/__tests__/fixtures.ts +13 -0
  23. package/cellUtils/index.ts +40 -2
  24. package/dateUtils/index.ts +11 -0
  25. package/focusManager/index.ts +1 -1
  26. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
  27. package/functionUtils/__tests__/functionUtils.test.js +244 -248
  28. package/headersUtils/index.ts +1 -0
  29. package/inflatedUrlUtils/index.ts +4 -4
  30. package/localizationUtils/__tests__/localizationUtils.test.ts +17 -13
  31. package/localizationUtils/index.ts +6 -3
  32. package/logger/index.ts +1 -1
  33. package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
  34. package/manifestUtils/defaultManifestConfigurations/player.js +10 -1
  35. package/manifestUtils/index.js +5 -1
  36. package/manifestUtils/secondaryImage/index.js +18 -15
  37. package/modalState/index.ts +57 -0
  38. package/navigationUtils/index.ts +56 -7
  39. package/numberUtils/index.ts +4 -0
  40. package/package.json +3 -2
  41. package/playerUtils/configurationGenerator.ts +11 -1
  42. package/pluginUtils/index.ts +11 -7
  43. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
  44. package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
  45. package/reactHooks/cell-click/__tests__/index.test.js +6 -2
  46. package/reactHooks/cell-click/index.ts +2 -2
  47. package/reactHooks/device/index.ts +0 -1
  48. package/reactHooks/device/useIsTablet.tsx +28 -3
  49. package/reactHooks/device/useMemoizedIsTablet.ts +1 -1
  50. package/reactHooks/device/useOrientation.tsx +3 -1
  51. package/reactHooks/feed/__tests__/useInflatedUrl.test.ts +18 -3
  52. package/reactHooks/feed/useInflatedUrl.ts +44 -15
  53. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
  54. package/reactHooks/index.ts +2 -0
  55. package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +66 -59
  56. package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
  57. package/reactHooks/layout/index.ts +2 -1
  58. package/reactHooks/layout/types/index.ts +2 -0
  59. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
  60. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
  61. package/reactHooks/layout/useDimensions/useDimensions.ts +13 -7
  62. package/reactHooks/navigation/__mocks__/index.ts +15 -0
  63. package/reactHooks/navigation/__mocks__/useNavigation.ts +7 -0
  64. package/reactHooks/navigation/__tests__/index.test.tsx +234 -78
  65. package/reactHooks/navigation/index.ts +251 -85
  66. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
  67. package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
  68. package/reactHooks/screen/index.ts +2 -0
  69. package/reactHooks/screen/useScreenContext.ts +2 -2
  70. package/reactHooks/screen/useScreenData.ts +1 -1
  71. package/reactHooks/screen/useTargetScreenData.ts +7 -0
  72. package/reactHooks/state/useRivers.ts +3 -1
  73. package/reactHooks/useListenEventBusEvent.ts +1 -4
  74. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
  75. package/riverComponetsMeasurementProvider/index.tsx +2 -2
  76. package/stringUtils/index.ts +5 -0
  77. package/testUtils/getByTestId.ts +14 -0
  78. package/testUtils/index.tsx +38 -23
  79. package/types.ts +4 -0
  80. package/reactHooks/device/useIsTablet.android.tsx +0 -14
  81. package/reactHooks/device/useIsTablet.ios.tsx +0 -7
  82. package/reactHooks/device/useIsTablet.web.tsx +0 -3
@@ -1,14 +1,5 @@
1
1
  import * as R from "ramda";
2
2
 
3
- jest.mock("react-native", () => {
4
- return {
5
- ...jest.requireActual("react-native"),
6
- Animating: {
7
- timing: jest.fn(() => ({ start: jest.fn() })),
8
- },
9
- };
10
- });
11
-
12
3
  const {
13
4
  debounce,
14
5
  noop,
@@ -88,328 +79,333 @@ function resolveAfterTimeout(func) {
88
79
  });
89
80
  }
90
81
 
91
- describe("debounce", () => {
92
- beforeEach(clearMocks);
93
-
94
- describe("when immediate is false", () => {
82
+ describe("functionUtils", () => {
83
+ describe("debounce", () => {
95
84
  beforeEach(clearMocks);
96
85
 
97
- it("calls the debounced function only once after the delay", () => {
98
- const debounced = debounce({ fn, wait, immediate: false });
99
- debounced(...debouncedArgs);
100
- debounced(...debouncedArgs);
86
+ describe("when immediate is false", () => {
87
+ beforeEach(clearMocks);
101
88
 
102
- expect(fn).not.toHaveBeenCalled();
89
+ it("calls the debounced function only once after the delay", () => {
90
+ const debounced = debounce({ fn, wait, immediate: false });
91
+ debounced(...debouncedArgs);
92
+ debounced(...debouncedArgs);
103
93
 
104
- return resolveAfterTimeout(() => {
105
- expect(fn).toHaveBeenCalledTimes(1);
106
- expect(fn).toHaveBeenNthCalledWith(1, ...debouncedArgs);
107
- expect(fn).not.toHaveBeenCalledTimes(2);
108
- expect.assertions(4);
94
+ expect(fn).not.toHaveBeenCalled();
95
+
96
+ return resolveAfterTimeout(() => {
97
+ expect(fn).toHaveBeenCalledTimes(1);
98
+ expect(fn).toHaveBeenNthCalledWith(1, ...debouncedArgs);
99
+ expect(fn).not.toHaveBeenCalledTimes(2);
100
+ expect.assertions(4);
101
+ });
109
102
  });
110
103
  });
111
- });
112
104
 
113
- describe("when immediate is true", () => {
114
- beforeEach(clearMocks);
105
+ describe("when immediate is true", () => {
106
+ beforeEach(clearMocks);
115
107
 
116
- it("calls the debounced function only once during the delay", () => {
117
- const debounced = debounce({ fn, wait });
118
- debounced(...debouncedArgs);
119
- debounced(...debouncedArgs);
108
+ it("calls the debounced function only once during the delay", () => {
109
+ const debounced = debounce({ fn, wait });
110
+ debounced(...debouncedArgs);
111
+ debounced(...debouncedArgs);
120
112
 
121
- expect(fn).toHaveBeenCalledTimes(1);
122
- expect(fn).toHaveBeenNthCalledWith(1, ...debouncedArgs);
113
+ expect(fn).toHaveBeenCalledTimes(1);
114
+ expect(fn).toHaveBeenNthCalledWith(1, ...debouncedArgs);
123
115
 
124
- return resolveAfterTimeout(() => {
125
- expect(fn).not.toHaveBeenCalledTimes(2);
126
- expect.assertions(3);
116
+ return resolveAfterTimeout(() => {
117
+ expect(fn).not.toHaveBeenCalledTimes(2);
118
+ expect.assertions(3);
119
+ });
127
120
  });
128
121
  });
129
- });
130
122
 
131
- describe("when no context is provided", () => {
132
- beforeEach(clearMocks);
123
+ describe("when no context is provided", () => {
124
+ beforeEach(clearMocks);
133
125
 
134
- it("invokes the debounce function on the current context", () => {
135
- const debounced = debounce({ fn, wait });
136
- debounced(...debouncedArgs);
126
+ it("invokes the debounce function on the current context", () => {
127
+ const debounced = debounce({ fn, wait });
128
+ debounced(...debouncedArgs);
137
129
 
138
- return resolveAfterTimeout(() => {
139
- expect(global.debouncedArgs).toEqual(debouncedArgs);
140
- expect(context.debouncedArgs).toBeUndefined();
130
+ return resolveAfterTimeout(() => {
131
+ expect(global.debouncedArgs).toEqual(debouncedArgs);
132
+ expect(context.debouncedArgs).toBeUndefined();
133
+ });
141
134
  });
142
135
  });
143
- });
144
136
 
145
- describe("when a context is provided", () => {
146
- beforeEach(clearMocks);
137
+ describe("when a context is provided", () => {
138
+ beforeEach(clearMocks);
147
139
 
148
- it("invokes the debounce function on the provided context", (done) => {
149
- const debounced = debounce({ fn, wait, context });
150
- debounced(...debouncedArgs);
140
+ it("invokes the debounce function on the provided context", (done) => {
141
+ const debounced = debounce({ fn, wait, context });
142
+ debounced(...debouncedArgs);
151
143
 
152
- resolveAfterTimeout(() => {
153
- expect(global.debouncedArgs).toBeUndefined();
154
- expect(context.debouncedArgs).toEqual(debouncedArgs);
155
- done();
144
+ resolveAfterTimeout(() => {
145
+ expect(global.debouncedArgs).toBeUndefined();
146
+ expect(context.debouncedArgs).toEqual(debouncedArgs);
147
+ done();
148
+ });
156
149
  });
157
150
  });
158
151
  });
159
- });
160
-
161
- describe("noop", () => {
162
- it("does nothing", () => {
163
- expect(noop()).toBeUndefined();
164
- });
165
- });
166
-
167
- describe("clearObject", () => {
168
- it("should clear original object without changing the reference", () => {
169
- // arrange
170
- const originalObject = {
171
- handlers: { a: [1, 2, 3], b: { c: 1, d: 2 }, c: 3 },
172
- };
173
152
 
174
- const objCopy1 = originalObject.handlers;
175
- const objCopy2 = originalObject.handlers;
176
-
177
- // act
178
- clearObject(originalObject);
179
- // assert
180
- expect(objCopy1).not.toContain("a");
181
- expect(objCopy2).not.toContain("b");
182
- });
183
- });
184
-
185
- describe("subscriber", () => {
186
- const initialObj = {
187
- foo: "bar",
188
- method() {
189
- return this.foo;
190
- },
191
- };
192
-
193
- const handler = jest.fn();
194
- const handler2 = jest.fn();
195
- const event = "some_event";
196
- const args = ["foo", { bar: 42 }];
197
-
198
- beforeEach(() => {
199
- handler.mockClear();
200
- handler2.mockClear();
153
+ describe("noop", () => {
154
+ it("does nothing", () => {
155
+ expect(noop()).toBeUndefined();
156
+ });
201
157
  });
202
158
 
203
- it("returns the original object with additional methods", () => {
204
- const expectedInitialObj = Object.assign({}, initialObj);
205
- expect(subscriber(expectedInitialObj)).toMatchSnapshot();
206
- expect(expectedInitialObj.handlers).not.toBeUndefined();
159
+ describe("clearObject", () => {
160
+ it("should clear original object without changing the reference", () => {
161
+ // arrange
162
+ const originalObject = {
163
+ handlers: { a: [1, 2, 3], b: { c: 1, d: 2 }, c: 3 },
164
+ };
165
+
166
+ const objCopy1 = originalObject.handlers;
167
+ const objCopy2 = originalObject.handlers;
168
+
169
+ // act
170
+ clearObject(originalObject);
171
+ // assert
172
+ expect(objCopy1).not.toContain("a");
173
+ expect(objCopy2).not.toContain("b");
174
+ });
207
175
  });
208
176
 
209
- it("can be invoked without args", () => {
210
- expect(subscriber()).toMatchSnapshot();
211
- });
177
+ describe("subscriber", () => {
178
+ const initialObj = {
179
+ foo: "bar",
180
+ method() {
181
+ return this.foo;
182
+ },
183
+ };
212
184
 
213
- describe("on", () => {
214
- it("returns the object so handlers can be chained", () => {
215
- const subscribable = subscriber();
216
- expect(subscribable.on(event, handler)).toEqual(subscribable);
217
- });
218
- });
185
+ const handler = jest.fn();
186
+ const handler2 = jest.fn();
187
+ const event = "some_event";
188
+ const args = ["foo", { bar: 42 }];
219
189
 
220
- describe("invokeHandler", () => {
221
190
  beforeEach(() => {
222
191
  handler.mockClear();
223
192
  handler2.mockClear();
224
193
  });
225
194
 
226
- it("returns the object so handlers invokation can be chained", () => {
227
- const subscribable = subscriber();
228
- expect(subscribable.invokeHandler(event, ...args)).toEqual(subscribable);
195
+ it("returns the original object with additional methods", () => {
196
+ const expectedInitialObj = Object.assign({}, initialObj);
197
+ expect(subscriber(expectedInitialObj)).toMatchSnapshot();
198
+ expect(expectedInitialObj.handlers).not.toBeUndefined();
229
199
  });
230
200
 
231
- it("invokes the declared handlers", () => {
232
- subscriber()
233
- .on(event, handler)
234
- .on(event, handler2)
235
- .invokeHandler(event, ...args);
236
-
237
- expect(handler).toHaveBeenCalledTimes(1);
238
- expect(handler2).toHaveBeenCalledTimes(1);
239
-
240
- expect(handler).toHaveBeenCalledWith(...args, expect.any(Function));
241
- expect(handler2).toHaveBeenCalledWith(...args, expect.any(Function));
201
+ it("can be invoked without args", () => {
202
+ expect(subscriber()).toMatchSnapshot();
242
203
  });
243
- });
244
204
 
245
- describe("dispose", () => {
246
- const handlerWithDispose = jest.fn((...handlerArgs) => {
247
- const dispose = R.last(handlerArgs);
248
- dispose();
205
+ describe("on", () => {
206
+ it("returns the object so handlers can be chained", () => {
207
+ const subscribable = subscriber();
208
+ expect(subscribable.on(event, handler)).toEqual(subscribable);
209
+ });
249
210
  });
250
211
 
251
- const handlerWithDisposeAll = jest.fn((...handlerArgs) => {
252
- const dispose = R.last(handlerArgs);
253
- dispose({ disposeAll: true });
254
- });
212
+ describe("invokeHandler", () => {
213
+ beforeEach(() => {
214
+ handler.mockClear();
215
+ handler2.mockClear();
216
+ });
255
217
 
256
- beforeEach(() => {
257
- handler.mockClear();
258
- handler2.mockClear();
259
- handlerWithDispose.mockClear();
260
- handlerWithDisposeAll.mockClear();
261
- });
218
+ it("returns the object so handlers invokation can be chained", () => {
219
+ const subscribable = subscriber();
262
220
 
263
- it("removes the specific handler", () => {
264
- const subscriberObj = subscriber()
265
- .on(event, handlerWithDispose)
266
- .on(event, handler);
221
+ expect(subscribable.invokeHandler(event, ...args)).toEqual(
222
+ subscribable
223
+ );
224
+ });
267
225
 
268
- subscriberObj.invokeHandler(event, ...args);
269
- expect(handlerWithDispose).toHaveBeenCalledTimes(1);
270
- expect(handler).toHaveBeenCalledTimes(1);
226
+ it("invokes the declared handlers", () => {
227
+ subscriber()
228
+ .on(event, handler)
229
+ .on(event, handler2)
230
+ .invokeHandler(event, ...args);
271
231
 
272
- subscriberObj.invokeHandler(event, ...args);
273
- expect(handlerWithDispose).toHaveBeenCalledTimes(1);
274
- expect(handler).toHaveBeenCalledTimes(2);
232
+ expect(handler).toHaveBeenCalledTimes(1);
233
+ expect(handler2).toHaveBeenCalledTimes(1);
275
234
 
276
- expect(subscriberObj.handlers[event]).toHaveLength(1);
235
+ expect(handler).toHaveBeenCalledWith(...args, expect.any(Function));
236
+ expect(handler2).toHaveBeenCalledWith(...args, expect.any(Function));
237
+ });
277
238
  });
278
239
 
279
- it("removes all the handlers if the specific option is provided", () => {
280
- const subscriberObj = subscriber()
281
- .on(event, handlerWithDisposeAll)
282
- .on(event, handler);
240
+ describe("dispose", () => {
241
+ const handlerWithDispose = jest.fn((...handlerArgs) => {
242
+ const dispose = R.last(handlerArgs);
243
+ dispose();
244
+ });
245
+
246
+ const handlerWithDisposeAll = jest.fn((...handlerArgs) => {
247
+ const dispose = R.last(handlerArgs);
248
+ dispose({ disposeAll: true });
249
+ });
283
250
 
284
- expect(subscriberObj).toMatchObject({
285
- invokeHandler: expect.any(Function),
286
- removeHandler: expect.any(Function),
287
- on: expect.any(Function),
251
+ beforeEach(() => {
252
+ handler.mockClear();
253
+ handler2.mockClear();
254
+ handlerWithDispose.mockClear();
255
+ handlerWithDisposeAll.mockClear();
288
256
  });
289
257
 
290
- expect(subscriberObj?.handlers?.[event]).toHaveLength(2);
258
+ it("removes the specific handler", () => {
259
+ const subscriberObj = subscriber()
260
+ .on(event, handlerWithDispose)
261
+ .on(event, handler);
291
262
 
292
- subscriberObj.invokeHandler(event, ...args);
263
+ subscriberObj.invokeHandler(event, ...args);
264
+ expect(handlerWithDispose).toHaveBeenCalledTimes(1);
265
+ expect(handler).toHaveBeenCalledTimes(1);
293
266
 
294
- expect(handlerWithDisposeAll).toHaveBeenCalledTimes(1);
295
- expect(handler).toHaveBeenCalledTimes(1);
267
+ subscriberObj.invokeHandler(event, ...args);
268
+ expect(handlerWithDispose).toHaveBeenCalledTimes(1);
269
+ expect(handler).toHaveBeenCalledTimes(2);
296
270
 
297
- expect(subscriberObj.handlers?.[event]).not.toBeDefined();
271
+ expect(subscriberObj.handlers[event]).toHaveLength(1);
272
+ });
298
273
 
299
- subscriberObj.invokeHandler(event, ...args);
274
+ it("removes all the handlers if the specific option is provided", () => {
275
+ const subscriberObj = subscriber()
276
+ .on(event, handlerWithDisposeAll)
277
+ .on(event, handler);
300
278
 
301
- expect(handler).toHaveBeenCalledTimes(1);
302
- expect(handlerWithDisposeAll).toHaveBeenCalledTimes(1);
279
+ expect(subscriberObj).toMatchObject({
280
+ invokeHandler: expect.any(Function),
281
+ removeHandler: expect.any(Function),
282
+ on: expect.any(Function),
283
+ });
303
284
 
304
- expect(subscriberObj.handlers?.[event]).not.toBeDefined();
305
- });
285
+ expect(subscriberObj?.handlers?.[event]).toHaveLength(2);
306
286
 
307
- it("should utilize existing subscriber object", () => {
308
- const mockExistingHandler = jest.fn();
287
+ subscriberObj.invokeHandler(event, ...args);
309
288
 
310
- const subscriberObjects = Object.create({
311
- [event]: {
312
- handlers: {
313
- [event]: [mockExistingHandler],
314
- },
315
- },
316
- });
289
+ expect(handlerWithDisposeAll).toHaveBeenCalledTimes(1);
290
+ expect(handler).toHaveBeenCalledTimes(1);
317
291
 
318
- const subscriberObj = subscriber(subscriberObjects[event]).on(
319
- event,
320
- handler
321
- );
292
+ expect(subscriberObj.handlers?.[event]).not.toBeDefined();
322
293
 
323
- expect(subscriberObj).toMatchObject({
324
- invokeHandler: expect.any(Function),
325
- removeHandler: expect.any(Function),
326
- on: expect.any(Function),
294
+ subscriberObj.invokeHandler(event, ...args);
295
+
296
+ expect(handler).toHaveBeenCalledTimes(1);
297
+ expect(handlerWithDisposeAll).toHaveBeenCalledTimes(1);
298
+
299
+ expect(subscriberObj.handlers?.[event]).not.toBeDefined();
327
300
  });
328
301
 
329
- expect(subscriberObj.handlers[event][0]).toBe(mockExistingHandler);
330
- expect(subscriberObj.handlers[event][1]).toBe(handler);
331
- expect(subscriberObj?.handlers?.[event]).toHaveLength(2);
302
+ it("should utilize existing subscriber object", () => {
303
+ const mockExistingHandler = jest.fn();
304
+
305
+ const subscriberObjects = Object.create({
306
+ [event]: {
307
+ handlers: {
308
+ [event]: [mockExistingHandler],
309
+ },
310
+ },
311
+ });
312
+
313
+ const subscriberObj = subscriber(subscriberObjects[event]).on(
314
+ event,
315
+ handler
316
+ );
332
317
 
333
- subscriberObj.invokeHandler(event, ...args);
318
+ expect(subscriberObj).toMatchObject({
319
+ invokeHandler: expect.any(Function),
320
+ removeHandler: expect.any(Function),
321
+ on: expect.any(Function),
322
+ });
334
323
 
335
- expect(handler).toHaveBeenCalledTimes(1);
336
- expect(mockExistingHandler).toHaveBeenCalledTimes(1);
324
+ expect(subscriberObj.handlers[event][0]).toBe(mockExistingHandler);
325
+ expect(subscriberObj.handlers[event][1]).toBe(handler);
326
+ expect(subscriberObj?.handlers?.[event]).toHaveLength(2);
337
327
 
338
- expect(subscriberObj.handlers?.[event]).toBeDefined();
339
- expect(subscriberObj.handlers?.[event]).toHaveLength(2);
328
+ subscriberObj.invokeHandler(event, ...args);
329
+
330
+ expect(handler).toHaveBeenCalledTimes(1);
331
+ expect(mockExistingHandler).toHaveBeenCalledTimes(1);
332
+
333
+ expect(subscriberObj.handlers?.[event]).toBeDefined();
334
+ expect(subscriberObj.handlers?.[event]).toHaveLength(2);
335
+ });
340
336
  });
341
337
  });
342
- });
343
338
 
344
- describe("parseJsonIfNeeded", () => {
345
- const data = { foo: "bar" };
346
- const json = JSON.stringify(data);
339
+ describe("parseJsonIfNeeded", () => {
340
+ const data = { foo: "bar" };
341
+ const json = JSON.stringify(data);
347
342
 
348
- describe("when parsing a json", () => {
349
- it("returns the object", () => {
350
- expect(parseJsonIfNeeded(json)).toEqual(data);
343
+ describe("when parsing a json", () => {
344
+ it("returns the object", () => {
345
+ expect(parseJsonIfNeeded(json)).toEqual(data);
346
+ });
351
347
  });
352
- });
353
348
 
354
- describe("when parsing data that is not a json", () => {
355
- it("returns the initial value", () => {
356
- expect(parseJsonIfNeeded(data)).toEqual(data);
349
+ describe("when parsing data that is not a json", () => {
350
+ it("returns the initial value", () => {
351
+ expect(parseJsonIfNeeded(data)).toEqual(data);
352
+ });
357
353
  });
358
354
  });
359
- });
360
-
361
- describe("isFunction", () => {
362
- it("return true if named function is passed", () => {
363
- function foo() {
364
- return null;
365
- }
366
355
 
367
- const currentResult = isFunction(foo);
368
- expect(currentResult).toBe(true);
369
- });
356
+ describe("isFunction", () => {
357
+ it("return true if named function is passed", () => {
358
+ function foo() {
359
+ return null;
360
+ }
370
361
 
371
- it("return true if arrow function is passed", () => {
372
- const currentResult = isFunction(() => null);
373
- expect(currentResult).toBe(true);
374
- });
362
+ const currentResult = isFunction(foo);
363
+ expect(currentResult).toBe(true);
364
+ });
375
365
 
376
- it("return true if anonymous function is passed", () => {
377
- const currentResult = isFunction(function () {
378
- return null;
366
+ it("return true if arrow function is passed", () => {
367
+ const currentResult = isFunction(() => null);
368
+ expect(currentResult).toBe(true);
379
369
  });
380
370
 
381
- expect(currentResult).toBe(true);
382
- });
371
+ it("return true if anonymous function is passed", () => {
372
+ const currentResult = isFunction(function () {
373
+ return null;
374
+ });
383
375
 
384
- it("returns false otherwise", () => {
385
- expect(isFunction({})).toBe(false);
386
- expect(isFunction([])).toBe(false);
387
- expect(isFunction(false)).toBe(false);
388
- expect(isFunction(null)).toBe(false);
389
- expect(isFunction(undefined)).toBe(false);
390
- expect(isFunction(0)).toBe(false);
391
- expect(isFunction("foo")).toBe(false);
392
- expect(isFunction(123)).toBe(false);
393
- expect(isFunction(true)).toBe(false);
394
- });
395
- });
376
+ expect(currentResult).toBe(true);
377
+ });
396
378
 
397
- describe("extractDataFromProperty", () => {
398
- it("returns the value of the path if exists", () => {
399
- expect(
400
- extractDataFromProperty(VAL.propToExtract, DATA)(MAPPING.showOne)
401
- ).toEqual(DATA.extensions.playlistId);
379
+ it("returns false otherwise", () => {
380
+ expect(isFunction({})).toBe(false);
381
+ expect(isFunction([])).toBe(false);
382
+ expect(isFunction(false)).toBe(false);
383
+ expect(isFunction(null)).toBe(false);
384
+ expect(isFunction(undefined)).toBe(false);
385
+ expect(isFunction(0)).toBe(false);
386
+ expect(isFunction("foo")).toBe(false);
387
+ expect(isFunction(123)).toBe(false);
388
+ expect(isFunction(true)).toBe(false);
389
+ });
402
390
  });
403
391
 
404
- it("returns null if the path or prop does not exist", () => {
405
- expect(
406
- extractDataFromProperty(VAL.propToExtract, DATA)(MAPPING.showTwo)
407
- ).toBe(null);
408
- });
392
+ describe("extractDataFromProperty", () => {
393
+ it("returns the value of the path if exists", () => {
394
+ expect(
395
+ extractDataFromProperty(VAL.propToExtract, DATA)(MAPPING.showOne)
396
+ ).toEqual(DATA.extensions.playlistId);
397
+ });
398
+
399
+ it("returns null if the path or prop does not exist", () => {
400
+ expect(
401
+ extractDataFromProperty(VAL.propToExtract, DATA)(MAPPING.showTwo)
402
+ ).toBe(null);
403
+ });
409
404
 
410
- it("returns null if the property does not exist on mapped object", () => {
411
- expect(
412
- extractDataFromProperty(VAL.propToExtract, DATA)(MAPPING.showThree)
413
- ).toBe(null);
405
+ it("returns null if the property does not exist on mapped object", () => {
406
+ expect(
407
+ extractDataFromProperty(VAL.propToExtract, DATA)(MAPPING.showThree)
408
+ ).toBe(null);
409
+ });
414
410
  });
415
411
  });
@@ -28,5 +28,6 @@ export const getAppDataHeaders = (screenId: string) => {
28
28
  "x-applicaster-signed-device-info-token": appData.signedDeviceInfoToken,
29
29
  "x-applicaster-device-make": appData.deviceMake,
30
30
  "x-applicaster-device-model": appData.deviceModel,
31
+ "x-applicaster-uuid": appData?.uuid,
31
32
  };
32
33
  };
@@ -1,4 +1,4 @@
1
- import { last, head, isNil, includes, all, pathOr } from "ramda";
1
+ import { last, head, isNil, includes, pathOr } from "ramda";
2
2
 
3
3
  const stripBrackets = (path) => {
4
4
  const withoutPrepened = last(path.split("{{"));
@@ -13,15 +13,15 @@ const hasValue = (context) => (path) => {
13
13
  return !isNil(value);
14
14
  };
15
15
 
16
- export const isEnoughDataToInflateString = (context, string): boolean => {
16
+ export const getMissingValues = (context, string): string[] => {
17
17
  if (!includes("{{", string)) {
18
- return true;
18
+ return [];
19
19
  }
20
20
 
21
21
  const SEARCH_REGEX = new RegExp(/{{.*?}}/g);
22
22
  const paths = string.toString().match(SEARCH_REGEX);
23
23
 
24
- return all(hasValue(context), paths);
24
+ return paths.filter((path) => !hasValue(context)(path));
25
25
  };
26
26
 
27
27
  export const isNonInflatedUrl = (url: string): boolean =>
@@ -1,3 +1,5 @@
1
+ import * as ReactNative from "react-native";
2
+
1
3
  const mocked_state = {
2
4
  remoteConfigurations: { localizations: {} },
3
5
  appData: {
@@ -12,19 +14,21 @@ jest.doMock("react-redux", () => ({
12
14
  useSelector: jest.fn((fn) => fn(mocked_state)),
13
15
  }));
14
16
 
15
- jest.doMock("react-native", () => ({
16
- NativeModules: {
17
- SettingsManager: {
18
- getConstants: jest.fn(() => ({
19
- settings: { AppleLanguages: mocked_locale },
20
- })),
21
- },
22
- QuickBrickCommunicationModule: {
23
- languageLocale: "en",
24
- countryLocale: "US",
25
- },
26
- },
27
- }));
17
+ const SettingsManager = {
18
+ getConstants: jest.fn(() => ({
19
+ settings: { AppleLanguages: mocked_locale },
20
+ })),
21
+ };
22
+
23
+ const QuickBrickCommunicationModule = {
24
+ languageLocale: "en",
25
+ countryLocale: "US",
26
+ };
27
+
28
+ ReactNative.NativeModules.SettingsManager = SettingsManager;
29
+
30
+ ReactNative.NativeModules.QuickBrickCommunicationModule =
31
+ QuickBrickCommunicationModule;
28
32
 
29
33
  const { useIsRTL } = require("../index");
30
34