@applicaster/zapp-react-native-utils 12.0.0-alpha.7725319213 → 12.0.0-alpha.8058554488
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/actionsExecutor/ActionExecutorContext.tsx +16 -8
- package/analyticsUtils/__tests__/analyticsManager.test.js +75 -73
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/appUtils/HooksManager/index.js +3 -1
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +12 -3
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
- package/appUtils/keyCodes/keys.web.js +1 -0
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +53 -0
- package/appUtils/playerManager/conts.ts +5 -0
- package/appUtils/playerManager/player.ts +47 -6
- package/appUtils/playerManager/playerFactory.ts +12 -10
- package/appUtils/playerManager/playerNative.ts +31 -0
- package/appUtils/playerManager/usePlayerState.tsx +13 -1
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +50 -0
- package/cellUtils/__tests__/cellUtils.test.ts +59 -0
- package/cellUtils/__tests__/fixtures.ts +13 -0
- package/cellUtils/index.ts +33 -2
- package/focusManager/index.ts +1 -1
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
- package/functionUtils/__tests__/functionUtils.test.js +244 -248
- package/headersUtils/index.ts +1 -0
- package/localizationUtils/__tests__/localizationUtils.test.ts +17 -13
- package/localizationUtils/index.ts +6 -3
- package/logger/index.ts +1 -1
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +10 -1
- package/manifestUtils/index.js +5 -1
- package/manifestUtils/secondaryImage/index.js +18 -15
- package/modalState/index.ts +57 -0
- package/navigationUtils/index.ts +56 -7
- package/package.json +3 -2
- package/playerUtils/configurationGenerator.ts +11 -1
- package/pluginUtils/index.ts +2 -2
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
- package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
- package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +66 -59
- package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
- package/reactHooks/layout/types/index.ts +2 -0
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
- package/reactHooks/layout/useDimensions/useDimensions.ts +13 -7
- package/reactHooks/navigation/__mocks__/index.ts +15 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +7 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +234 -78
- package/reactHooks/navigation/index.ts +251 -85
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
- package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
- package/reactHooks/screen/index.ts +2 -0
- package/reactHooks/screen/useScreenContext.ts +2 -2
- package/reactHooks/screen/useScreenData.ts +1 -1
- package/reactHooks/state/useRivers.ts +3 -1
- package/reactHooks/useListenEventBusEvent.ts +1 -4
- package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
- package/riverComponetsMeasurementProvider/index.tsx +2 -2
- package/stringUtils/index.ts +5 -0
- package/testUtils/getByTestId.ts +14 -0
- package/testUtils/index.tsx +38 -23
|
@@ -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("
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
describe("when immediate is false", () => {
|
|
82
|
+
describe("functionUtils", () => {
|
|
83
|
+
describe("debounce", () => {
|
|
95
84
|
beforeEach(clearMocks);
|
|
96
85
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
debounced(...debouncedArgs);
|
|
100
|
-
debounced(...debouncedArgs);
|
|
86
|
+
describe("when immediate is false", () => {
|
|
87
|
+
beforeEach(clearMocks);
|
|
101
88
|
|
|
102
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
114
|
-
|
|
105
|
+
describe("when immediate is true", () => {
|
|
106
|
+
beforeEach(clearMocks);
|
|
115
107
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
122
|
-
|
|
113
|
+
expect(fn).toHaveBeenCalledTimes(1);
|
|
114
|
+
expect(fn).toHaveBeenNthCalledWith(1, ...debouncedArgs);
|
|
123
115
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
116
|
+
return resolveAfterTimeout(() => {
|
|
117
|
+
expect(fn).not.toHaveBeenCalledTimes(2);
|
|
118
|
+
expect.assertions(3);
|
|
119
|
+
});
|
|
127
120
|
});
|
|
128
121
|
});
|
|
129
|
-
});
|
|
130
122
|
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
describe("when no context is provided", () => {
|
|
124
|
+
beforeEach(clearMocks);
|
|
133
125
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
126
|
+
it("invokes the debounce function on the current context", () => {
|
|
127
|
+
const debounced = debounce({ fn, wait });
|
|
128
|
+
debounced(...debouncedArgs);
|
|
137
129
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
return resolveAfterTimeout(() => {
|
|
131
|
+
expect(global.debouncedArgs).toEqual(debouncedArgs);
|
|
132
|
+
expect(context.debouncedArgs).toBeUndefined();
|
|
133
|
+
});
|
|
141
134
|
});
|
|
142
135
|
});
|
|
143
|
-
});
|
|
144
136
|
|
|
145
|
-
|
|
146
|
-
|
|
137
|
+
describe("when a context is provided", () => {
|
|
138
|
+
beforeEach(clearMocks);
|
|
147
139
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
it("invokes the debounce function on the provided context", (done) => {
|
|
141
|
+
const debounced = debounce({ fn, wait, context });
|
|
142
|
+
debounced(...debouncedArgs);
|
|
151
143
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
177
|
+
describe("subscriber", () => {
|
|
178
|
+
const initialObj = {
|
|
179
|
+
foo: "bar",
|
|
180
|
+
method() {
|
|
181
|
+
return this.foo;
|
|
182
|
+
},
|
|
183
|
+
};
|
|
212
184
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
|
227
|
-
const
|
|
228
|
-
expect(
|
|
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("
|
|
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
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
212
|
+
describe("invokeHandler", () => {
|
|
213
|
+
beforeEach(() => {
|
|
214
|
+
handler.mockClear();
|
|
215
|
+
handler2.mockClear();
|
|
216
|
+
});
|
|
255
217
|
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
221
|
+
expect(subscribable.invokeHandler(event, ...args)).toEqual(
|
|
222
|
+
subscribable
|
|
223
|
+
);
|
|
224
|
+
});
|
|
267
225
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
226
|
+
it("invokes the declared handlers", () => {
|
|
227
|
+
subscriber()
|
|
228
|
+
.on(event, handler)
|
|
229
|
+
.on(event, handler2)
|
|
230
|
+
.invokeHandler(event, ...args);
|
|
271
231
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
expect(handler).toHaveBeenCalledTimes(2);
|
|
232
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
233
|
+
expect(handler2).toHaveBeenCalledTimes(1);
|
|
275
234
|
|
|
276
|
-
|
|
235
|
+
expect(handler).toHaveBeenCalledWith(...args, expect.any(Function));
|
|
236
|
+
expect(handler2).toHaveBeenCalledWith(...args, expect.any(Function));
|
|
237
|
+
});
|
|
277
238
|
});
|
|
278
239
|
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
.
|
|
282
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
251
|
+
beforeEach(() => {
|
|
252
|
+
handler.mockClear();
|
|
253
|
+
handler2.mockClear();
|
|
254
|
+
handlerWithDispose.mockClear();
|
|
255
|
+
handlerWithDisposeAll.mockClear();
|
|
288
256
|
});
|
|
289
257
|
|
|
290
|
-
|
|
258
|
+
it("removes the specific handler", () => {
|
|
259
|
+
const subscriberObj = subscriber()
|
|
260
|
+
.on(event, handlerWithDispose)
|
|
261
|
+
.on(event, handler);
|
|
291
262
|
|
|
292
|
-
|
|
263
|
+
subscriberObj.invokeHandler(event, ...args);
|
|
264
|
+
expect(handlerWithDispose).toHaveBeenCalledTimes(1);
|
|
265
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
293
266
|
|
|
294
|
-
|
|
295
|
-
|
|
267
|
+
subscriberObj.invokeHandler(event, ...args);
|
|
268
|
+
expect(handlerWithDispose).toHaveBeenCalledTimes(1);
|
|
269
|
+
expect(handler).toHaveBeenCalledTimes(2);
|
|
296
270
|
|
|
297
|
-
|
|
271
|
+
expect(subscriberObj.handlers[event]).toHaveLength(1);
|
|
272
|
+
});
|
|
298
273
|
|
|
299
|
-
|
|
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
|
-
|
|
302
|
-
|
|
279
|
+
expect(subscriberObj).toMatchObject({
|
|
280
|
+
invokeHandler: expect.any(Function),
|
|
281
|
+
removeHandler: expect.any(Function),
|
|
282
|
+
on: expect.any(Function),
|
|
283
|
+
});
|
|
303
284
|
|
|
304
|
-
|
|
305
|
-
});
|
|
285
|
+
expect(subscriberObj?.handlers?.[event]).toHaveLength(2);
|
|
306
286
|
|
|
307
|
-
|
|
308
|
-
const mockExistingHandler = jest.fn();
|
|
287
|
+
subscriberObj.invokeHandler(event, ...args);
|
|
309
288
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
handlers: {
|
|
313
|
-
[event]: [mockExistingHandler],
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
});
|
|
289
|
+
expect(handlerWithDisposeAll).toHaveBeenCalledTimes(1);
|
|
290
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
317
291
|
|
|
318
|
-
|
|
319
|
-
event,
|
|
320
|
-
handler
|
|
321
|
-
);
|
|
292
|
+
expect(subscriberObj.handlers?.[event]).not.toBeDefined();
|
|
322
293
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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
|
-
|
|
318
|
+
expect(subscriberObj).toMatchObject({
|
|
319
|
+
invokeHandler: expect.any(Function),
|
|
320
|
+
removeHandler: expect.any(Function),
|
|
321
|
+
on: expect.any(Function),
|
|
322
|
+
});
|
|
334
323
|
|
|
335
|
-
|
|
336
|
-
|
|
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
|
-
|
|
339
|
-
|
|
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
|
-
|
|
346
|
-
|
|
339
|
+
describe("parseJsonIfNeeded", () => {
|
|
340
|
+
const data = { foo: "bar" };
|
|
341
|
+
const json = JSON.stringify(data);
|
|
347
342
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
343
|
+
describe("when parsing a json", () => {
|
|
344
|
+
it("returns the object", () => {
|
|
345
|
+
expect(parseJsonIfNeeded(json)).toEqual(data);
|
|
346
|
+
});
|
|
351
347
|
});
|
|
352
|
-
});
|
|
353
348
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
-
|
|
368
|
-
|
|
369
|
-
|
|
356
|
+
describe("isFunction", () => {
|
|
357
|
+
it("return true if named function is passed", () => {
|
|
358
|
+
function foo() {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
370
361
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
});
|
|
362
|
+
const currentResult = isFunction(foo);
|
|
363
|
+
expect(currentResult).toBe(true);
|
|
364
|
+
});
|
|
375
365
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
366
|
+
it("return true if arrow function is passed", () => {
|
|
367
|
+
const currentResult = isFunction(() => null);
|
|
368
|
+
expect(currentResult).toBe(true);
|
|
379
369
|
});
|
|
380
370
|
|
|
381
|
-
|
|
382
|
-
|
|
371
|
+
it("return true if anonymous function is passed", () => {
|
|
372
|
+
const currentResult = isFunction(function () {
|
|
373
|
+
return null;
|
|
374
|
+
});
|
|
383
375
|
|
|
384
|
-
|
|
385
|
-
|
|
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
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
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
|
});
|
package/headersUtils/index.ts
CHANGED
|
@@ -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,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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
|
@@ -64,10 +64,13 @@ export function getIsRTLFromLocalizations(localizations): boolean {
|
|
|
64
64
|
return R.contains(localeToUse, RTL_LOCALES);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
const remoteConfigLocalizationSelector = R.path([
|
|
68
|
+
"remoteConfigurations",
|
|
69
|
+
"localizations",
|
|
70
|
+
]);
|
|
71
|
+
|
|
67
72
|
export function useIsRTL(): boolean {
|
|
68
|
-
const localizations = useSelector(
|
|
69
|
-
R.path(["remoteConfigurations", "localizations"])
|
|
70
|
-
);
|
|
73
|
+
const localizations = useSelector(remoteConfigLocalizationSelector);
|
|
71
74
|
|
|
72
75
|
return getIsRTLFromLocalizations(localizations);
|
|
73
76
|
}
|
package/logger/index.ts
CHANGED