@applicaster/quick-brick-core 14.0.0-rc.8 → 15.0.0-rc.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/App/ActionSetters/index.ts +0 -1
- package/App/ActionsProvider/__tests__/__snapshots__/ActionsProvider.test.js.snap +2 -2
- package/App/ActionsProvider/index.js +1 -1
- package/App/AppStateDecorator/index.tsx +9 -4
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +4 -12
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/usePresentSchemeHandler.test.tsx +34 -41
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useUrlSchemeHandler.test.tsx +1 -1
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useOpenSchemeHandler/index.ts +7 -2
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/usePresentSchemeHandler.ts +6 -4
- package/App/DeepLinking/URLSchemeHandler/__tests__/URLSchemeHandler.test.tsx +4 -4
- package/App/ErrorBoundary/index.tsx +4 -0
- package/App/ModalProvider/ModalBottomSheet/DraggableBottomSheet/index.tsx +2 -2
- package/App/ModalProvider/ModalBottomSheet/ModalBottomSheetFrame.tsx +1 -1
- package/App/ModalProvider/ModalChildrenWrapper/index.tsx +2 -7
- package/App/ModalProvider/ModalPresenter.tsx +2 -1
- package/App/NavigationProvider/NavigationProvider.tsx +29 -9
- package/App/NavigationProvider/navigator/__tests__/__snapshots__/reducer.test.ts.snap +0 -177
- package/App/NavigationProvider/navigator/__tests__/reducer.test.ts +2 -70
- package/App/NavigationProvider/navigator/reducer.ts +30 -101
- package/App/NavigationProvider/navigator/selectors.ts +2 -1
- package/App/NetworkStatusProvider/__tests__/NetworkStatusProvider.test.tsx +11 -15
- package/App/RouterDecorator/__tests__/routerDecorator.test.js +3 -3
- package/App/StoreConnector/__tests__/storeConnector.test.js +6 -9
- package/App/StoreConnector/index.ts +1 -1
- package/App/ThemeManager/index.tsx +9 -1
- package/App/__tests__/createQuickBrickApp.test.js +13 -10
- package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.tsx +29 -25
- package/App/appLifeCycleManager/index.tsx +5 -6
- package/App/components/ZappAppWrapper.ts +3 -0
- package/App/components/ZappAppWrapper.web.ts +3 -0
- package/App/index.tsx +28 -22
- package/App/remoteContextReloader/__tests__/getRemoteContextData.test.js +11 -12
- package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +5 -3
- package/README.md +0 -4
- package/const/index.ts +6 -0
- package/createZappApp/__tests__/createZappApp.test.js +11 -0
- package/createZappApp/index.tsx +4 -5
- package/index.d.ts +0 -1
- package/package.json +9 -21
- package/renderZappApp/index.js +2 -1
|
@@ -13,7 +13,6 @@ exports[`ACTIONS matches snapshot 1`] = `
|
|
|
13
13
|
"PUSH": "PUSH",
|
|
14
14
|
"REPLACE": "REPLACE",
|
|
15
15
|
"REPLACE_TOP": "REPLACE_TOP",
|
|
16
|
-
"SET_LOCATION": "SET_LOCATION",
|
|
17
16
|
"SET_NESTED_CONTENT": "SET_NESTED_CONTENT",
|
|
18
17
|
"SET_VIDEO_MODAL_ITEM": "SET_VIDEO_MODAL_ITEM",
|
|
19
18
|
}
|
|
@@ -22,30 +21,6 @@ exports[`ACTIONS matches snapshot 1`] = `
|
|
|
22
21
|
exports[`reducer when a back action is dispatched push, back, push, back does what it's supposed to do 1`] = `
|
|
23
22
|
{
|
|
24
23
|
"state1": {
|
|
25
|
-
"location": {
|
|
26
|
-
"key": "mocked-uuid",
|
|
27
|
-
"pathname": "/river/A1234",
|
|
28
|
-
"state": {
|
|
29
|
-
"entry": undefined,
|
|
30
|
-
"options": undefined,
|
|
31
|
-
"screen": {
|
|
32
|
-
"home": true,
|
|
33
|
-
"home_offline": true,
|
|
34
|
-
"hooks": {
|
|
35
|
-
"preload_plugins": [],
|
|
36
|
-
},
|
|
37
|
-
"id": "A1234",
|
|
38
|
-
"name": "Home",
|
|
39
|
-
"navigations": [
|
|
40
|
-
{
|
|
41
|
-
"id": "nav_id",
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
"supports_offline": false,
|
|
45
|
-
"type": "general_content",
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
24
|
"options": {
|
|
50
25
|
"videoModal": {
|
|
51
26
|
"item": null,
|
|
@@ -86,36 +61,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
86
61
|
},
|
|
87
62
|
},
|
|
88
63
|
"state2": {
|
|
89
|
-
"location": {
|
|
90
|
-
"key": "mocked-uuid",
|
|
91
|
-
"pathname": "/river/A1234/river/B7890",
|
|
92
|
-
"state": {
|
|
93
|
-
"entry": {
|
|
94
|
-
"id": "C0987",
|
|
95
|
-
"title": "Entry",
|
|
96
|
-
"type": {
|
|
97
|
-
"value": "feed",
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
"options": undefined,
|
|
101
|
-
"screen": {
|
|
102
|
-
"home": false,
|
|
103
|
-
"home_offline": false,
|
|
104
|
-
"hooks": {
|
|
105
|
-
"preload_plugins": [],
|
|
106
|
-
},
|
|
107
|
-
"id": "B5678",
|
|
108
|
-
"name": "Screen name",
|
|
109
|
-
"navigations": [
|
|
110
|
-
{
|
|
111
|
-
"id": "nav_id",
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
"supports_offline": false,
|
|
115
|
-
"type": "general_content",
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
64
|
"options": {
|
|
120
65
|
"videoModal": {
|
|
121
66
|
"item": null,
|
|
@@ -187,36 +132,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
187
132
|
},
|
|
188
133
|
},
|
|
189
134
|
"state3": {
|
|
190
|
-
"location": {
|
|
191
|
-
"key": "mocked-uuid",
|
|
192
|
-
"pathname": "/river/A1234/river/B7890/river/C0987",
|
|
193
|
-
"state": {
|
|
194
|
-
"entry": {
|
|
195
|
-
"id": "D1234",
|
|
196
|
-
"title": "Entry 2",
|
|
197
|
-
"type": {
|
|
198
|
-
"value": "video",
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
"options": undefined,
|
|
202
|
-
"screen": {
|
|
203
|
-
"home": false,
|
|
204
|
-
"home_offline": false,
|
|
205
|
-
"hooks": {
|
|
206
|
-
"preload_plugins": [],
|
|
207
|
-
},
|
|
208
|
-
"id": "C9090",
|
|
209
|
-
"name": "Screen 2 name",
|
|
210
|
-
"navigations": [
|
|
211
|
-
{
|
|
212
|
-
"id": "nav_id",
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
"supports_offline": false,
|
|
216
|
-
"type": "general_content",
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
135
|
"options": {
|
|
221
136
|
"videoModal": {
|
|
222
137
|
"item": null,
|
|
@@ -319,37 +234,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
319
234
|
},
|
|
320
235
|
},
|
|
321
236
|
"state4": {
|
|
322
|
-
"location": {
|
|
323
|
-
"action": "PUSH",
|
|
324
|
-
"key": "mocked-uuid",
|
|
325
|
-
"pathname": "/river/A1234/river/B7890",
|
|
326
|
-
"state": {
|
|
327
|
-
"entry": {
|
|
328
|
-
"id": "C0987",
|
|
329
|
-
"title": "Entry",
|
|
330
|
-
"type": {
|
|
331
|
-
"value": "feed",
|
|
332
|
-
},
|
|
333
|
-
},
|
|
334
|
-
"options": undefined,
|
|
335
|
-
"screen": {
|
|
336
|
-
"home": false,
|
|
337
|
-
"home_offline": false,
|
|
338
|
-
"hooks": {
|
|
339
|
-
"preload_plugins": [],
|
|
340
|
-
},
|
|
341
|
-
"id": "B5678",
|
|
342
|
-
"name": "Screen name",
|
|
343
|
-
"navigations": [
|
|
344
|
-
{
|
|
345
|
-
"id": "nav_id",
|
|
346
|
-
},
|
|
347
|
-
],
|
|
348
|
-
"supports_offline": false,
|
|
349
|
-
"type": "general_content",
|
|
350
|
-
},
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
237
|
"options": {
|
|
354
238
|
"videoModal": {
|
|
355
239
|
"item": null,
|
|
@@ -421,36 +305,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
421
305
|
},
|
|
422
306
|
},
|
|
423
307
|
"state5": {
|
|
424
|
-
"location": {
|
|
425
|
-
"key": "mocked-uuid",
|
|
426
|
-
"pathname": "/river/A1234/river/B7890/river/D5678",
|
|
427
|
-
"state": {
|
|
428
|
-
"entry": {
|
|
429
|
-
"id": "C0987",
|
|
430
|
-
"title": "Entry",
|
|
431
|
-
"type": {
|
|
432
|
-
"value": "feed",
|
|
433
|
-
},
|
|
434
|
-
},
|
|
435
|
-
"options": undefined,
|
|
436
|
-
"screen": {
|
|
437
|
-
"home": false,
|
|
438
|
-
"home_offline": false,
|
|
439
|
-
"hooks": {
|
|
440
|
-
"preload_plugins": [],
|
|
441
|
-
},
|
|
442
|
-
"id": "B5678",
|
|
443
|
-
"name": "Screen name",
|
|
444
|
-
"navigations": [
|
|
445
|
-
{
|
|
446
|
-
"id": "nav_id",
|
|
447
|
-
},
|
|
448
|
-
],
|
|
449
|
-
"supports_offline": false,
|
|
450
|
-
"type": "general_content",
|
|
451
|
-
},
|
|
452
|
-
},
|
|
453
|
-
},
|
|
454
308
|
"options": {
|
|
455
309
|
"videoModal": {
|
|
456
310
|
"item": null,
|
|
@@ -553,37 +407,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
553
407
|
},
|
|
554
408
|
},
|
|
555
409
|
"state6": {
|
|
556
|
-
"location": {
|
|
557
|
-
"action": "PUSH",
|
|
558
|
-
"key": "mocked-uuid",
|
|
559
|
-
"pathname": "/river/A1234/river/B7890",
|
|
560
|
-
"state": {
|
|
561
|
-
"entry": {
|
|
562
|
-
"id": "C0987",
|
|
563
|
-
"title": "Entry",
|
|
564
|
-
"type": {
|
|
565
|
-
"value": "feed",
|
|
566
|
-
},
|
|
567
|
-
},
|
|
568
|
-
"options": undefined,
|
|
569
|
-
"screen": {
|
|
570
|
-
"home": false,
|
|
571
|
-
"home_offline": false,
|
|
572
|
-
"hooks": {
|
|
573
|
-
"preload_plugins": [],
|
|
574
|
-
},
|
|
575
|
-
"id": "B5678",
|
|
576
|
-
"name": "Screen name",
|
|
577
|
-
"navigations": [
|
|
578
|
-
{
|
|
579
|
-
"id": "nav_id",
|
|
580
|
-
},
|
|
581
|
-
],
|
|
582
|
-
"supports_offline": false,
|
|
583
|
-
"type": "general_content",
|
|
584
|
-
},
|
|
585
|
-
},
|
|
586
|
-
},
|
|
587
410
|
"options": {
|
|
588
411
|
"videoModal": {
|
|
589
412
|
"item": null,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import reducer, {
|
|
2
2
|
ACTIONS,
|
|
3
|
-
push,
|
|
4
|
-
replace,
|
|
5
3
|
back,
|
|
6
4
|
initialState,
|
|
5
|
+
push,
|
|
6
|
+
replace,
|
|
7
7
|
} from "../reducer";
|
|
8
8
|
|
|
9
9
|
jest.mock("uuid");
|
|
@@ -181,24 +181,6 @@ describe("reducer", () => {
|
|
|
181
181
|
expect(newState.options.navBar).toEqual(initialState.options.navBar);
|
|
182
182
|
expect(newState2.options.navBar).toEqual(initialState.options.navBar);
|
|
183
183
|
});
|
|
184
|
-
|
|
185
|
-
it("updates the location properties of the state", () => {
|
|
186
|
-
expect(newState).toHaveProperty("location");
|
|
187
|
-
expect(newState.location).toHaveProperty("pathname", route);
|
|
188
|
-
|
|
189
|
-
expect(newState.location).toHaveProperty("state", { screen: homeScreen });
|
|
190
|
-
|
|
191
|
-
expect(newState2).toHaveProperty("location");
|
|
192
|
-
expect(newState2.location).toHaveProperty("pathname", route2);
|
|
193
|
-
|
|
194
|
-
expect(newState2.location).toHaveProperty(
|
|
195
|
-
"state",
|
|
196
|
-
expect.objectContaining({
|
|
197
|
-
screen,
|
|
198
|
-
entry,
|
|
199
|
-
})
|
|
200
|
-
);
|
|
201
|
-
});
|
|
202
184
|
});
|
|
203
185
|
|
|
204
186
|
describe("when a replace action is dispatched", () => {
|
|
@@ -245,24 +227,6 @@ describe("reducer", () => {
|
|
|
245
227
|
expect(newState.options.navBar).toEqual(initialState.options.navBar);
|
|
246
228
|
expect(newState2.options.navBar).toEqual(initialState.options.navBar);
|
|
247
229
|
});
|
|
248
|
-
|
|
249
|
-
it("updates the location properties of the state", () => {
|
|
250
|
-
expect(newState).toHaveProperty("location");
|
|
251
|
-
expect(newState.location).toHaveProperty("pathname", route);
|
|
252
|
-
|
|
253
|
-
expect(newState.location).toHaveProperty("state", {
|
|
254
|
-
screen: homeScreen,
|
|
255
|
-
entry: undefined,
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
expect(newState2).toHaveProperty("location");
|
|
259
|
-
expect(newState2.location).toHaveProperty("pathname", route2);
|
|
260
|
-
|
|
261
|
-
expect(newState2.location).toHaveProperty("state", {
|
|
262
|
-
screen,
|
|
263
|
-
entry,
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
230
|
});
|
|
267
231
|
|
|
268
232
|
describe("when a back action is dispatched", () => {
|
|
@@ -300,30 +264,6 @@ describe("reducer", () => {
|
|
|
300
264
|
expect(newState2.options.navBar).toEqual(initialState.options.navBar);
|
|
301
265
|
expect(finalState.options.navBar).toEqual(initialState.options.navBar);
|
|
302
266
|
});
|
|
303
|
-
|
|
304
|
-
it("updates the location properties of the state", () => {
|
|
305
|
-
expect(newState).toHaveProperty("location");
|
|
306
|
-
expect(newState.location).toHaveProperty("pathname", route);
|
|
307
|
-
|
|
308
|
-
expect(newState.location).toHaveProperty("state", {
|
|
309
|
-
screen: homeScreen,
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
expect(newState2).toHaveProperty("location");
|
|
313
|
-
expect(newState2.location).toHaveProperty("pathname", route2);
|
|
314
|
-
|
|
315
|
-
expect(newState2.location).toHaveProperty("state", {
|
|
316
|
-
screen,
|
|
317
|
-
entry,
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
expect(finalState).toHaveProperty("location");
|
|
321
|
-
expect(finalState.location).toHaveProperty("pathname", route);
|
|
322
|
-
|
|
323
|
-
expect(finalState.location).toHaveProperty("state", {
|
|
324
|
-
screen: homeScreen,
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
267
|
});
|
|
328
268
|
|
|
329
269
|
describe("push, back, push, back", () => {
|
|
@@ -382,14 +322,6 @@ describe("reducer", () => {
|
|
|
382
322
|
entry: undefined,
|
|
383
323
|
});
|
|
384
324
|
|
|
385
|
-
expect(finalState).toHaveProperty("location");
|
|
386
|
-
expect(finalState.location).toHaveProperty("pathname", route);
|
|
387
|
-
|
|
388
|
-
expect(finalState.location).toHaveProperty("state", {
|
|
389
|
-
screen: homeScreen,
|
|
390
|
-
entry: undefined,
|
|
391
|
-
});
|
|
392
|
-
|
|
393
325
|
expect(finalState).toEqual(newState);
|
|
394
326
|
});
|
|
395
327
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
3
|
|
|
4
|
+
import { last } from "@applicaster/zapp-react-native-utils/utils";
|
|
5
|
+
|
|
4
6
|
import {
|
|
5
7
|
firstStackEntriesSelector,
|
|
6
8
|
previousStackEntriesSelector,
|
|
@@ -18,7 +20,6 @@ export const initialState: NavigationReducerState = {
|
|
|
18
20
|
mainStack: [],
|
|
19
21
|
modal: null,
|
|
20
22
|
},
|
|
21
|
-
location: { key: "", pathname: "/", state: null },
|
|
22
23
|
options: {
|
|
23
24
|
videoModal: {
|
|
24
25
|
visible: false,
|
|
@@ -38,7 +39,6 @@ export enum ACTIONS {
|
|
|
38
39
|
BACK_PLAYER_NESTED_CONTENT = "BACK_PLAYER_NESTED_CONTENT",
|
|
39
40
|
REPLACE_TOP = "REPLACE_TOP",
|
|
40
41
|
SET_NESTED_CONTENT = "SET_NESTED_CONTENT",
|
|
41
|
-
SET_LOCATION = "SET_LOCATION",
|
|
42
42
|
OPEN_VIDEO_MODAL = "OPEN_VIDEO_MODAL",
|
|
43
43
|
CLOSE_VIDEO_MODAL = "CLOSE_VIDEO_MODAL",
|
|
44
44
|
MINIMISE_VIDEO_MODAL = "MINIMISE_VIDEO_MODAL",
|
|
@@ -174,9 +174,9 @@ function backPlayerNestedContent(state) {
|
|
|
174
174
|
return findPlayableAndTruncate(currentState);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
function addNestedContent(stack, payload,
|
|
178
|
-
const
|
|
179
|
-
const stackIndex = R.findIndex(R.propEq("key",
|
|
177
|
+
function addNestedContent(stack, payload, targetStackEntry) {
|
|
178
|
+
const targetStackKey = targetStackEntry.key;
|
|
179
|
+
const stackIndex = R.findIndex(R.propEq("key", targetStackKey))(stack);
|
|
180
180
|
|
|
181
181
|
return R.adjust(
|
|
182
182
|
stackIndex,
|
|
@@ -190,7 +190,7 @@ function addNestedContent(stack, payload, locationState: LocationReducerState) {
|
|
|
190
190
|
|
|
191
191
|
function navigationStackReducer(
|
|
192
192
|
state: NavigationStackReducerState = initialState.stack,
|
|
193
|
-
{ type = "", payload
|
|
193
|
+
{ type = "", payload }: ReducerAction = { type: "" }
|
|
194
194
|
) {
|
|
195
195
|
switch (type) {
|
|
196
196
|
case ACTIONS.SET_NESTED_CONTENT:
|
|
@@ -199,7 +199,7 @@ function navigationStackReducer(
|
|
|
199
199
|
mainStack: addNestedContent(
|
|
200
200
|
state.mainStack,
|
|
201
201
|
navigationEntry(ACTIONS.REPLACE, payload as AnyRecord),
|
|
202
|
-
|
|
202
|
+
last(state.mainStack)
|
|
203
203
|
),
|
|
204
204
|
};
|
|
205
205
|
case ACTIONS.PUSH:
|
|
@@ -268,47 +268,6 @@ function navigationStackReducer(
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
function locationReducer(
|
|
272
|
-
state = initialState.location,
|
|
273
|
-
{ type, payload, meta = {} }
|
|
274
|
-
) {
|
|
275
|
-
const { route, key, screen, entry, options } = payload;
|
|
276
|
-
|
|
277
|
-
switch (type) {
|
|
278
|
-
case ACTIONS.BACK:
|
|
279
|
-
// eslint-disable-next-line no-case-declarations
|
|
280
|
-
const previousEntry = R.compose(
|
|
281
|
-
R.last,
|
|
282
|
-
payload.route ? firstStackEntriesSelector : previousStackEntriesSelector
|
|
283
|
-
)(meta);
|
|
284
|
-
|
|
285
|
-
if (previousEntry) {
|
|
286
|
-
const { state, key, action } = previousEntry;
|
|
287
|
-
|
|
288
|
-
return { pathname: previousEntry.route, state, key, action };
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
return state;
|
|
292
|
-
|
|
293
|
-
case ACTIONS.PUSH:
|
|
294
|
-
case ACTIONS.REPLACE:
|
|
295
|
-
case ACTIONS.REPLACE_TOP:
|
|
296
|
-
case ACTIONS.BACK_PLAYER_NESTED_CONTENT:
|
|
297
|
-
return { pathname: route, state: { screen, entry, options }, key };
|
|
298
|
-
|
|
299
|
-
case ACTIONS.SET_NESTED_CONTENT:
|
|
300
|
-
// eslint-disable-next-line no-case-declarations
|
|
301
|
-
const nestedEntry = navigationEntry(
|
|
302
|
-
ACTIONS.REPLACE,
|
|
303
|
-
payload as AnyRecord
|
|
304
|
-
);
|
|
305
|
-
|
|
306
|
-
return R.assocPath(["state", "nested"], nestedEntry.state, state);
|
|
307
|
-
default:
|
|
308
|
-
return state;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
271
|
/* Video Modal reducer */
|
|
313
272
|
export const setVideoModalOpen = (item, options, screen) => ({
|
|
314
273
|
type: ACTIONS.OPEN_VIDEO_MODAL,
|
|
@@ -354,43 +313,28 @@ export const videoModalReducer = (
|
|
|
354
313
|
switch (type) {
|
|
355
314
|
case ACTIONS.OPEN_VIDEO_MODAL: {
|
|
356
315
|
const { item, options } = payload;
|
|
316
|
+
const mode = options?.mode || MAXIMIZED;
|
|
357
317
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
R.lensProp("item"),
|
|
365
|
-
R.unless(R.tryCatch(R.propEq("id", item?.id), R.F), () => item)
|
|
366
|
-
)
|
|
367
|
-
)(state);
|
|
318
|
+
return {
|
|
319
|
+
...state,
|
|
320
|
+
visible: true,
|
|
321
|
+
mode,
|
|
322
|
+
item: state.item?.id !== item?.id ? item : state.item,
|
|
323
|
+
};
|
|
368
324
|
}
|
|
369
325
|
|
|
370
326
|
case ACTIONS.SET_VIDEO_MODAL_ITEM:
|
|
371
|
-
return
|
|
327
|
+
return { ...state, item: payload };
|
|
372
328
|
case ACTIONS.CLOSE_VIDEO_MODAL:
|
|
373
329
|
return initialState.options.videoModal;
|
|
374
330
|
case ACTIONS.FULLSCREEN_VIDEO_MODAL:
|
|
375
|
-
return
|
|
376
|
-
R.set(R.lensProp("mode"), FULLSCREEN),
|
|
377
|
-
R.set(R.lensProp("previousMode"), state.mode)
|
|
378
|
-
)(state);
|
|
331
|
+
return { ...state, mode: FULLSCREEN, previousMode: state.mode };
|
|
379
332
|
case ACTIONS.MINIMISE_VIDEO_MODAL:
|
|
380
|
-
return
|
|
381
|
-
R.set(R.lensProp("mode"), MINIMIZED),
|
|
382
|
-
R.set(R.lensProp("previousMode"), state.mode)
|
|
383
|
-
)(state);
|
|
333
|
+
return { ...state, mode: MINIMIZED, previousMode: state.mode };
|
|
384
334
|
case ACTIONS.MAXIMISE_VIDEO_MODAL:
|
|
385
|
-
return
|
|
386
|
-
R.set(R.lensProp("mode"), MAXIMIZED),
|
|
387
|
-
R.set(R.lensProp("previousMode"), state.mode)
|
|
388
|
-
)(state);
|
|
335
|
+
return { ...state, mode: MAXIMIZED, previousMode: state.mode };
|
|
389
336
|
case ACTIONS.PIP:
|
|
390
|
-
return
|
|
391
|
-
R.set(R.lensProp("mode"), PIP),
|
|
392
|
-
R.set(R.lensProp("previousMode"), state.mode)
|
|
393
|
-
)(state);
|
|
337
|
+
return { ...state, mode: PIP, previousMode: state.mode };
|
|
394
338
|
}
|
|
395
339
|
};
|
|
396
340
|
|
|
@@ -406,34 +350,19 @@ export default function navigationReducer(
|
|
|
406
350
|
case ACTIONS.REPLACE_TOP:
|
|
407
351
|
case ACTIONS.BACK:
|
|
408
352
|
case ACTIONS.BACK_PLAYER_NESTED_CONTENT:
|
|
409
|
-
return
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
type,
|
|
414
|
-
payload,
|
|
415
|
-
meta: state,
|
|
416
|
-
}),
|
|
417
|
-
},
|
|
418
|
-
state
|
|
419
|
-
);
|
|
353
|
+
return {
|
|
354
|
+
...state,
|
|
355
|
+
stack: navigationStackReducer(state.stack, { type, payload }),
|
|
356
|
+
};
|
|
420
357
|
|
|
421
358
|
case ACTIONS.SET_NESTED_CONTENT:
|
|
422
|
-
return
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
location: applyReducer(locationReducer, {
|
|
430
|
-
type,
|
|
431
|
-
payload,
|
|
432
|
-
meta: state.stack,
|
|
433
|
-
}),
|
|
434
|
-
},
|
|
435
|
-
state
|
|
436
|
-
);
|
|
359
|
+
return {
|
|
360
|
+
...state,
|
|
361
|
+
stack: navigationStackReducer(state.stack, {
|
|
362
|
+
type,
|
|
363
|
+
payload,
|
|
364
|
+
}),
|
|
365
|
+
};
|
|
437
366
|
|
|
438
367
|
case ACTIONS.OPEN_VIDEO_MODAL:
|
|
439
368
|
case ACTIONS.CLOSE_VIDEO_MODAL:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
|
-
import { createSelector } from "
|
|
2
|
+
import { createSelector } from "@reduxjs/toolkit";
|
|
3
3
|
|
|
4
4
|
import { getPathAttributes } from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
5
5
|
|
|
@@ -7,6 +7,7 @@ const riverSelector = R.prop("rivers");
|
|
|
7
7
|
const pathnameSelector = R.prop("pathname");
|
|
8
8
|
const navigationStackSelector = R.prop("stack");
|
|
9
9
|
|
|
10
|
+
// @TODO extract to zapp-react-native-redux/selectors, remove ramda
|
|
10
11
|
export const homeRiverSelector = createSelector(
|
|
11
12
|
riverSelector,
|
|
12
13
|
R.compose(R.find(R.propEq("home", true)), R.values)
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import { renderHook, act } from "@testing-library/react-hooks";
|
|
4
|
-
import configureStore from "redux-mock-store";
|
|
5
|
-
import thunk from "redux-thunk";
|
|
6
4
|
import { NetworkStatusContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NetworkStatusContext";
|
|
7
5
|
import { NetworkStatusProvider } from "../NetworkStatusProvider";
|
|
8
|
-
import {
|
|
6
|
+
import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
9
7
|
import NetInfo from "@react-native-community/netinfo";
|
|
10
8
|
|
|
11
|
-
const mockStore = configureStore([thunk]);
|
|
12
|
-
|
|
13
9
|
const NetInfoMock = {
|
|
14
10
|
type: "cellular",
|
|
15
11
|
details: {
|
|
@@ -24,9 +20,9 @@ const NetInfoMock = {
|
|
|
24
20
|
const getWrapper = (store) => ({
|
|
25
21
|
// eslint-disable-next-line react/prop-types,react/display-name
|
|
26
22
|
wrapper: ({ children }) => (
|
|
27
|
-
<
|
|
23
|
+
<WrappedWithProviders store={store}>
|
|
28
24
|
<NetworkStatusProvider>{children}</NetworkStatusProvider>
|
|
29
|
-
</
|
|
25
|
+
</WrappedWithProviders>
|
|
30
26
|
),
|
|
31
27
|
});
|
|
32
28
|
|
|
@@ -41,9 +37,9 @@ const useNetInfoMock = () => {
|
|
|
41
37
|
|
|
42
38
|
describe("NetworkStatusProvider", function () {
|
|
43
39
|
it("should return netInfoData", function () {
|
|
44
|
-
const store =
|
|
40
|
+
const store = {
|
|
45
41
|
plugins: [{}],
|
|
46
|
-
}
|
|
42
|
+
};
|
|
47
43
|
|
|
48
44
|
// @ts-ignore
|
|
49
45
|
jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
|
|
@@ -59,9 +55,9 @@ describe("NetworkStatusProvider", function () {
|
|
|
59
55
|
it("should call onConnectionLost callback when connection type changes to none", function () {
|
|
60
56
|
const onConnectionLost = jest.fn();
|
|
61
57
|
|
|
62
|
-
const store =
|
|
58
|
+
const store = {
|
|
63
59
|
plugins: [{ module: { networkHooks: { onConnectionLost } } }],
|
|
64
|
-
}
|
|
60
|
+
};
|
|
65
61
|
|
|
66
62
|
// @ts-ignore
|
|
67
63
|
jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
|
|
@@ -86,9 +82,9 @@ describe("NetworkStatusProvider", function () {
|
|
|
86
82
|
it("should call onConnectionRestored callback when connection type switches from none", function () {
|
|
87
83
|
const onConnectionRestored = jest.fn();
|
|
88
84
|
|
|
89
|
-
const store =
|
|
85
|
+
const store = {
|
|
90
86
|
plugins: [{ module: { networkHooks: { onConnectionRestored } } }],
|
|
91
|
-
}
|
|
87
|
+
};
|
|
92
88
|
|
|
93
89
|
// @ts-ignore
|
|
94
90
|
jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
|
|
@@ -123,9 +119,9 @@ describe("NetworkStatusProvider", function () {
|
|
|
123
119
|
it("should call onConnectionTypeChanged callback when connection type changes", function () {
|
|
124
120
|
const onConnectionTypeChanged = jest.fn();
|
|
125
121
|
|
|
126
|
-
const store =
|
|
122
|
+
const store = {
|
|
127
123
|
plugins: [{ module: { networkHooks: { onConnectionTypeChanged } } }],
|
|
128
|
-
}
|
|
124
|
+
};
|
|
129
125
|
|
|
130
126
|
// @ts-ignore
|
|
131
127
|
jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
4
|
|
|
5
5
|
import { createRouterDecorator } from "../index";
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@ describe("routerDecorator", () => {
|
|
|
26
26
|
const decorator = createRouterDecorator(Router);
|
|
27
27
|
const DecoratedComp = decorator(SomeComp);
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
expect(
|
|
29
|
+
const { toJSON } = render(<DecoratedComp foo="bar" />);
|
|
30
|
+
expect(toJSON()).toMatchSnapshot();
|
|
31
31
|
});
|
|
32
32
|
});
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as ReactIs from "react-is";
|
|
3
3
|
import { View, Text } from "react-native";
|
|
4
|
-
import {
|
|
5
|
-
import configureStore from "redux-mock-store";
|
|
4
|
+
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
6
5
|
|
|
7
6
|
import { storeConnector } from "../index";
|
|
8
|
-
import { Provider } from "react-redux";
|
|
9
7
|
|
|
10
8
|
const styles = { foo: "bar" };
|
|
11
9
|
const components = { grid: jest.fn() };
|
|
@@ -18,12 +16,12 @@ const Component = (props) => (
|
|
|
18
16
|
</View>
|
|
19
17
|
);
|
|
20
18
|
|
|
21
|
-
const store =
|
|
19
|
+
const store = {
|
|
22
20
|
styles,
|
|
23
21
|
components,
|
|
24
22
|
rivers,
|
|
25
23
|
appSettings,
|
|
26
|
-
}
|
|
24
|
+
};
|
|
27
25
|
|
|
28
26
|
describe("storeConnector", () => {
|
|
29
27
|
it("returns a Component", () => {
|
|
@@ -41,10 +39,9 @@ describe("storeConnector", () => {
|
|
|
41
39
|
it("passes the props to the component", () => {
|
|
42
40
|
const WrappedComponent = storeConnector(Component);
|
|
43
41
|
|
|
44
|
-
const { getByText, getByTestId } =
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
</Provider>
|
|
42
|
+
const { getByText, getByTestId } = renderWithProviders(
|
|
43
|
+
<WrappedComponent />,
|
|
44
|
+
store
|
|
48
45
|
);
|
|
49
46
|
|
|
50
47
|
expect(getByText("I'm a component")).toBeTruthy();
|