@applicaster/quick-brick-core 14.0.0-alpha.9119252693 → 14.0.0-alpha.9203091422

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.
@@ -12,18 +12,18 @@ exports[`Actions Provider renders children 1`] = `
12
12
  "$$typeof": Symbol(react.context),
13
13
  "Consumer": {
14
14
  "$$typeof": Symbol(react.context),
15
- "_calculateChangedBits": null,
16
15
  "_context": [Circular],
17
16
  },
18
17
  "Provider": {
19
18
  "$$typeof": Symbol(react.provider),
20
19
  "_context": [Circular],
21
20
  },
22
- "_calculateChangedBits": null,
23
21
  "_currentRenderer": null,
24
22
  "_currentRenderer2": {},
25
23
  "_currentValue": null,
26
24
  "_currentValue2": null,
25
+ "_defaultValue": null,
26
+ "_globalName": null,
27
27
  "_threadCount": 0,
28
28
  },
29
29
  "contextProvider": [Function],
@@ -19,6 +19,7 @@ function withAppManagerDecorator(
19
19
  currentState: AppStateStatus;
20
20
  isAvailable: boolean;
21
21
  plugins: QuickBrickPlugin[];
22
+ appStateListener: ReturnType<typeof AppState.addEventListener>;
22
23
 
23
24
  constructor(props: Props) {
24
25
  super(props);
@@ -30,11 +31,15 @@ function withAppManagerDecorator(
30
31
 
31
32
  componentDidMount() {
32
33
  this.plugins = this.getAppStatePlugins();
33
- AppState.addEventListener("change", this.onChange);
34
+
35
+ this.appStateListener = AppState.addEventListener(
36
+ "change",
37
+ this.onChange
38
+ );
34
39
  }
35
40
 
36
41
  componentWillUnmount() {
37
- AppState.removeEventListener("change", this.onChange);
42
+ this.appStateListener.remove();
38
43
  }
39
44
 
40
45
  dispatchAction(nextState: AppStateStatus, eventType) {
@@ -16,7 +16,7 @@ import {
16
16
  } from "../useOpenSchemeHandler/const";
17
17
  import { withInitialPlayerState } from "../useOpenSchemeHandler/utils";
18
18
 
19
- const { log_warning } = require("../../../logger");
19
+ import { log_warning } from "../../../logger";
20
20
 
21
21
  const rivers: Record<string, Partial<ZappRiver>> = {
22
22
  A1234: {
@@ -53,13 +53,10 @@ const navigator = {
53
53
  replace: jest.fn(),
54
54
  push: jest.fn(),
55
55
  goHome: jest.fn(),
56
- };
56
+ } as any;
57
57
 
58
58
  const mockStore = configureStore();
59
-
60
- jest
61
- .spyOn(useNavigationHooks, "useNavigation")
62
- .mockImplementation(() => navigator);
59
+ jest.spyOn(useNavigationHooks, "useNavigation").mockReturnValue(navigator);
63
60
 
64
61
  const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
65
62
  const feedLoaderSpy = jest.spyOn(feedLoader, "useFeedLoader");
@@ -72,7 +69,7 @@ jest.doMock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
72
69
  },
73
70
  }));
74
71
 
75
- jest.doMock("../../../logger", () => ({
72
+ jest.mock("../../../logger", () => ({
76
73
  log_info: jest.fn(),
77
74
  log_error: jest.fn(),
78
75
  log_warning: jest.fn(),
@@ -80,10 +77,6 @@ jest.doMock("../../../logger", () => ({
80
77
  log_debug: jest.fn(),
81
78
  }));
82
79
 
83
- jest.useFakeTimers({
84
- legacyFakeTimers: true,
85
- });
86
-
87
80
  // to use import instead of require it's required to use jest.mock above
88
81
  const { useOpenSchemeHandler } = require("../useOpenSchemeHandler");
89
82
 
@@ -192,7 +185,6 @@ describe("useOpenSchemeHandler", () => {
192
185
  it("doesn't log a warning", async () => {
193
186
  const tests = () => {
194
187
  expect(log_warning).not.toHaveBeenCalled();
195
- expect.assertions(1);
196
188
  };
197
189
 
198
190
  await testHook({ url, query, tests });
@@ -1,14 +1,13 @@
1
- import * as React from "react";
2
1
  import * as R from "ramda";
3
2
  import axios from "axios";
4
- import { renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react-native";
5
4
  import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
6
- import * as zappRedux from "@applicaster/zapp-react-native-redux";
7
5
  import * as helpers from "../../../helpers";
8
6
  import * as feedLoader from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
9
7
  import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
8
+ import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
9
+ import { usePresentSchemeHandler } from "../usePresentSchemeHandler";
10
10
 
11
- import { Provider } from "react-redux";
12
11
  import configureStore from "redux-mock-store";
13
12
 
14
13
  const rivers = {
@@ -20,23 +19,22 @@ const rivers = {
20
19
  const navigator = {
21
20
  currentRoute: "/river/A1234",
22
21
  replace: jest.fn(),
23
- };
22
+ goHome: jest.fn(),
23
+ } as any;
24
24
 
25
25
  const mockStore = configureStore();
26
26
 
27
- jest
28
- .spyOn(useNavigationHooks, "useNavigation")
29
- .mockImplementation(() => navigator);
27
+ jest.spyOn(useNavigationHooks, "useNavigation").mockReturnValue(navigator);
30
28
 
31
29
  const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
32
30
  const feedLoaderSpy = jest.spyOn(feedLoader, "useFeedLoader");
33
31
 
34
- const { usePresentSchemeHandler } = require("../usePresentSchemeHandler");
35
-
36
32
  const onFinish = jest.fn((cb) => {
37
33
  cb();
38
34
  });
39
35
 
36
+ jest.useFakeTimers();
37
+
40
38
  describe("usePresentSchemeHandler", () => {
41
39
  beforeEach(() => {
42
40
  onFinish.mockClear();
@@ -44,11 +42,7 @@ describe("usePresentSchemeHandler", () => {
44
42
  navigator.replace.mockClear();
45
43
  });
46
44
 
47
- const store = mockStore({ test: "test", rivers });
48
-
49
- const wrapper: React.FC<any> = ({ children }) => (
50
- <Provider store={store}>{children}</Provider>
51
- );
45
+ const store = { test: "test", rivers };
52
46
 
53
47
  describe("loading link url", () => {
54
48
  const query = { link_url: "http://applicaster.com" };
@@ -59,10 +53,11 @@ describe("usePresentSchemeHandler", () => {
59
53
 
60
54
  it("opens the link entry", () => {
61
55
  renderHook(() => usePresentSchemeHandler({ query, url, onFinish }), {
62
- wrapper,
56
+ wrapper: WrappedWithProviders,
57
+ initialProps: { store },
63
58
  });
64
59
 
65
- expect(onFinish).toBeCalled();
60
+ expect(onFinish).toHaveBeenCalled();
66
61
 
67
62
  expect(helperSpy).toBeCalledWith(
68
63
  expect.objectContaining({
@@ -96,7 +91,8 @@ describe("usePresentSchemeHandler", () => {
96
91
  onFinish,
97
92
  }),
98
93
  {
99
- wrapper,
94
+ wrapper: WrappedWithProviders,
95
+ initialProps: { store },
100
96
  }
101
97
  );
102
98
 
@@ -123,7 +119,8 @@ describe("usePresentSchemeHandler", () => {
123
119
  )}&show_nav_bar=true`;
124
120
 
125
121
  renderHook(() => usePresentSchemeHandler({ query, url, onFinish }), {
126
- wrapper,
122
+ wrapper: WrappedWithProviders,
123
+ initialProps: { store },
127
124
  });
128
125
 
129
126
  expect(onFinish).toBeCalled();
@@ -155,22 +152,22 @@ describe("usePresentSchemeHandler", () => {
155
152
  )}&screen_id=${screen_id}`;
156
153
 
157
154
  renderHook(() => usePresentSchemeHandler({ query, url, onFinish }), {
158
- wrapper,
155
+ wrapper: WrappedWithProviders,
156
+ initialProps: { store },
159
157
  });
160
158
 
161
159
  expect(onFinish).toBeCalled();
162
160
 
163
- expect(helperSpy).toBeCalledWith(
161
+ expect(helperSpy).toHaveBeenCalledWith(
164
162
  expect.objectContaining({
165
163
  data: {
166
164
  id: "url_scheme_entry",
167
165
  type: { value: "link" },
168
- screen_type: screen_id,
169
166
  link: { href: query.link_url, type: "text/html" },
170
167
  extensions: { showNavBar: false },
171
168
  },
172
- navigator,
173
- pushScreen: expect.anything(),
169
+ navigator: expect.anything(),
170
+ pushScreen: "http://applicaster.com",
174
171
  })
175
172
  );
176
173
  });
@@ -180,9 +177,7 @@ describe("usePresentSchemeHandler", () => {
180
177
  it("Re-sets app ready state and calls loadAppContextData with new river and cellStyles data", async () => {
181
178
  const store = mockStore({ test: "test" });
182
179
 
183
- const wrapper: React.FC<any> = ({ children }) => (
184
- <Provider store={store}>{children}</Provider>
185
- );
180
+ const wrapper = WrappedWithProviders;
186
181
 
187
182
  const query = {
188
183
  rivers_configuration_id: "test",
@@ -190,7 +185,6 @@ describe("usePresentSchemeHandler", () => {
190
185
 
191
186
  const storageSpy = jest.spyOn(sessionStorage, "getAllItems");
192
187
  const axiosGetSpy = jest.spyOn(axios, "get");
193
- const zappReduxSpy = jest.spyOn(zappRedux, "loadAppContextData");
194
188
 
195
189
  const getAllItems = jest.fn().mockResolvedValue({
196
190
  accountsAccountId: "accountsAccountId",
@@ -204,7 +198,6 @@ describe("usePresentSchemeHandler", () => {
204
198
 
205
199
  storageSpy.mockImplementation(getAllItems);
206
200
  axiosGetSpy.mockImplementation(get);
207
- zappReduxSpy.mockReturnValue(null);
208
201
 
209
202
  renderHook(() => usePresentSchemeHandler({ query, url: "", onFinish }), {
210
203
  wrapper,
@@ -217,13 +210,6 @@ describe("usePresentSchemeHandler", () => {
217
210
  actions?.find(R.propEq("type", "SET_APP_NOT_READY"))
218
211
  ).toBeDefined();
219
212
 
220
- expect(actions?.find(R.propEq("type", "SET_APP_READY"))).toBeDefined();
221
-
222
- expect(zappReduxSpy).toBeCalledWith(expect.any(Function), {
223
- cellStyles: "url",
224
- rivers: "url",
225
- });
226
-
227
213
  expect(navigator.replace).toBeCalledWith({});
228
214
  };
229
215
  });
@@ -261,7 +247,7 @@ describe("usePresentSchemeHandler", () => {
261
247
  },
262
248
  }),
263
249
  {
264
- wrapper,
250
+ wrapper: WrappedWithProviders,
265
251
  }
266
252
  );
267
253
 
@@ -293,7 +279,7 @@ describe("usePresentSchemeHandler", () => {
293
279
  },
294
280
  }),
295
281
  {
296
- wrapper,
282
+ wrapper: WrappedWithProviders,
297
283
  }
298
284
  );
299
285
 
@@ -325,7 +311,7 @@ describe("usePresentSchemeHandler", () => {
325
311
  },
326
312
  }),
327
313
  {
328
- wrapper,
314
+ wrapper: WrappedWithProviders,
329
315
  }
330
316
  );
331
317
 
@@ -357,7 +343,7 @@ describe("usePresentSchemeHandler", () => {
357
343
  },
358
344
  }),
359
345
  {
360
- wrapper,
346
+ wrapper: WrappedWithProviders,
361
347
  }
362
348
  );
363
349
 
@@ -5,7 +5,7 @@ import * as URLHandlersMap from "..";
5
5
  import { Provider } from "react-redux";
6
6
  import configureStore from "redux-mock-store";
7
7
 
8
- const { log_warning } = require("../../../logger");
8
+ import { log_warning } from "../../../logger";
9
9
 
10
10
  const mockStore = configureStore();
11
11
 
@@ -60,6 +60,10 @@ export class ErrorBoundary extends React.Component<Props> {
60
60
  useErrorStore.getState().setError(error, info, recoverable);
61
61
  }
62
62
 
63
+ static getDerivedStateFromError(_error) {
64
+ return { hasError: true };
65
+ }
66
+
63
67
  render() {
64
68
  return <ErrorBoundaryContent>{this.props.children}</ErrorBoundaryContent>;
65
69
  }
@@ -47,7 +47,7 @@ const getSheetHeight = ({ height, bottomOffset, maxHeight }) => {
47
47
  ios: height - bottomOffset,
48
48
  default:
49
49
  (height || maxHeight) -
50
- (!isAndroidVersionAtLeast(35) && isAndroidPlatform() ? bottomOffset : 0),
50
+ (isAndroidPlatform() && !isAndroidVersionAtLeast(35) ? bottomOffset : 0),
51
51
  });
52
52
  };
53
53
 
@@ -44,6 +44,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
44
44
  "supports_offline": false,
45
45
  "type": "general_content",
46
46
  },
47
+ "screenStateStore": [Function],
47
48
  },
48
49
  },
49
50
  "options": {
@@ -79,6 +80,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
79
80
  "supports_offline": false,
80
81
  "type": "general_content",
81
82
  },
83
+ "screenStateStore": undefined,
82
84
  },
83
85
  },
84
86
  ],
@@ -114,6 +116,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
114
116
  "supports_offline": false,
115
117
  "type": "general_content",
116
118
  },
119
+ "screenStateStore": [Function],
117
120
  },
118
121
  },
119
122
  "options": {
@@ -149,6 +152,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
149
152
  "supports_offline": false,
150
153
  "type": "general_content",
151
154
  },
155
+ "screenStateStore": undefined,
152
156
  },
153
157
  },
154
158
  {
@@ -180,6 +184,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
180
184
  "supports_offline": false,
181
185
  "type": "general_content",
182
186
  },
187
+ "screenStateStore": undefined,
183
188
  },
184
189
  },
185
190
  ],
@@ -215,6 +220,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
215
220
  "supports_offline": false,
216
221
  "type": "general_content",
217
222
  },
223
+ "screenStateStore": [Function],
218
224
  },
219
225
  },
220
226
  "options": {
@@ -250,6 +256,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
250
256
  "supports_offline": false,
251
257
  "type": "general_content",
252
258
  },
259
+ "screenStateStore": undefined,
253
260
  },
254
261
  },
255
262
  {
@@ -281,6 +288,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
281
288
  "supports_offline": false,
282
289
  "type": "general_content",
283
290
  },
291
+ "screenStateStore": undefined,
284
292
  },
285
293
  },
286
294
  {
@@ -312,6 +320,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
312
320
  "supports_offline": false,
313
321
  "type": "general_content",
314
322
  },
323
+ "screenStateStore": undefined,
315
324
  },
316
325
  },
317
326
  ],
@@ -348,6 +357,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
348
357
  "supports_offline": false,
349
358
  "type": "general_content",
350
359
  },
360
+ "screenStateStore": undefined,
351
361
  },
352
362
  },
353
363
  "options": {
@@ -383,6 +393,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
383
393
  "supports_offline": false,
384
394
  "type": "general_content",
385
395
  },
396
+ "screenStateStore": undefined,
386
397
  },
387
398
  },
388
399
  {
@@ -414,6 +425,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
414
425
  "supports_offline": false,
415
426
  "type": "general_content",
416
427
  },
428
+ "screenStateStore": undefined,
417
429
  },
418
430
  },
419
431
  ],
@@ -449,6 +461,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
449
461
  "supports_offline": false,
450
462
  "type": "general_content",
451
463
  },
464
+ "screenStateStore": [Function],
452
465
  },
453
466
  },
454
467
  "options": {
@@ -484,6 +497,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
484
497
  "supports_offline": false,
485
498
  "type": "general_content",
486
499
  },
500
+ "screenStateStore": undefined,
487
501
  },
488
502
  },
489
503
  {
@@ -515,6 +529,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
515
529
  "supports_offline": false,
516
530
  "type": "general_content",
517
531
  },
532
+ "screenStateStore": undefined,
518
533
  },
519
534
  },
520
535
  {
@@ -546,6 +561,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
546
561
  "supports_offline": false,
547
562
  "type": "general_content",
548
563
  },
564
+ "screenStateStore": undefined,
549
565
  },
550
566
  },
551
567
  ],
@@ -582,6 +598,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
582
598
  "supports_offline": false,
583
599
  "type": "general_content",
584
600
  },
601
+ "screenStateStore": undefined,
585
602
  },
586
603
  },
587
604
  "options": {
@@ -617,6 +634,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
617
634
  "supports_offline": false,
618
635
  "type": "general_content",
619
636
  },
637
+ "screenStateStore": undefined,
620
638
  },
621
639
  },
622
640
  {
@@ -648,6 +666,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
648
666
  "supports_offline": false,
649
667
  "type": "general_content",
650
668
  },
669
+ "screenStateStore": undefined,
651
670
  },
652
671
  },
653
672
  ],
@@ -5,6 +5,7 @@ import {
5
5
  firstStackEntriesSelector,
6
6
  previousStackEntriesSelector,
7
7
  } from "./selectors";
8
+ import { create, StoreApi, UseBoundStore } from "zustand";
8
9
 
9
10
  /* initial state */
10
11
 
@@ -120,12 +121,12 @@ export const setNestedContent = (
120
121
 
121
122
  const navigationEntry = (
122
123
  type: ActionValues,
123
- { route, screen, entry, key, options }: AnyRecord
124
+ { route, screen, entry, key, options, screenStateStore }: AnyRecord
124
125
  ) => ({
125
126
  key,
126
127
  action: type,
127
128
  route,
128
- state: { screen, entry, options },
129
+ state: { screen, entry, options, screenStateStore },
129
130
  });
130
131
 
131
132
  function updatePopActions(state) {
@@ -274,6 +275,25 @@ function locationReducer(
274
275
  ) {
275
276
  const { route, key, screen, entry, options } = payload;
276
277
 
278
+ const screenStateStore: UseBoundStore<StoreApi<ScreenStateStore>> =
279
+ create<ScreenStateStore>((set) => ({
280
+ data: {},
281
+ setValue: (key, value) =>
282
+ set((state) => ({
283
+ data: {
284
+ ...state.data,
285
+ [key]: value,
286
+ },
287
+ })),
288
+ removeValue: (key) =>
289
+ set((state) => {
290
+ const newData = { ...state.data };
291
+ delete newData[key];
292
+
293
+ return { data: newData };
294
+ }),
295
+ }));
296
+
277
297
  switch (type) {
278
298
  case ACTIONS.BACK:
279
299
  // eslint-disable-next-line no-case-declarations
@@ -294,14 +314,18 @@ function locationReducer(
294
314
  case ACTIONS.REPLACE:
295
315
  case ACTIONS.REPLACE_TOP:
296
316
  case ACTIONS.BACK_PLAYER_NESTED_CONTENT:
297
- return { pathname: route, state: { screen, entry, options }, key };
317
+ return {
318
+ pathname: route,
319
+ state: { screen, entry, options, screenStateStore },
320
+ key,
321
+ };
298
322
 
299
323
  case ACTIONS.SET_NESTED_CONTENT:
300
324
  // eslint-disable-next-line no-case-declarations
301
- const nestedEntry = navigationEntry(
302
- ACTIONS.REPLACE,
303
- payload as AnyRecord
304
- );
325
+ const nestedEntry = navigationEntry(ACTIONS.REPLACE, {
326
+ ...payload,
327
+ screenStateStore,
328
+ } as AnyRecord);
305
329
 
306
330
  return R.assocPath(["state", "nested"], nestedEntry.state, state);
307
331
  default:
@@ -405,18 +429,34 @@ export default function navigationReducer(
405
429
  case ACTIONS.REPLACE:
406
430
  case ACTIONS.REPLACE_TOP:
407
431
  case ACTIONS.BACK:
408
- case ACTIONS.BACK_PLAYER_NESTED_CONTENT:
409
- return R.evolve(
410
- {
411
- stack: applyReducer(navigationStackReducer, { type, payload }),
412
- location: applyReducer(locationReducer, {
413
- type,
414
- payload,
415
- meta: state,
416
- }),
417
- },
418
- state
419
- );
432
+ // eslint-disable-next-line
433
+ case ACTIONS.BACK_PLAYER_NESTED_CONTENT: {
434
+ // TODO: Check this solution with Pawel, does not work without it on tvs
435
+ const screenStateStore: UseBoundStore<StoreApi<ScreenStateStore>> =
436
+ create<ScreenStateStore>((set) => ({
437
+ data: {},
438
+ setValue: (key, value) =>
439
+ set((s) => ({ data: { ...s.data, [key]: value } })),
440
+ removeValue: (key) =>
441
+ set((s) => {
442
+ const data = { ...s.data };
443
+ delete data[key];
444
+
445
+ return { data };
446
+ }),
447
+ }));
448
+
449
+ const actionWithStore = {
450
+ type,
451
+ payload: { ...payload, screenStateStore },
452
+ meta: state,
453
+ };
454
+
455
+ const stack = applyReducer(navigationStackReducer, actionWithStore);
456
+ const location = applyReducer(locationReducer, actionWithStore);
457
+
458
+ return R.evolve({ stack, location }, state);
459
+ }
420
460
 
421
461
  case ACTIONS.SET_NESTED_CONTENT:
422
462
  return R.evolve(
@@ -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 { Provider } from "react-redux";
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
- <Provider store={store}>
23
+ <WrappedWithProviders store={store}>
28
24
  <NetworkStatusProvider>{children}</NetworkStatusProvider>
29
- </Provider>
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 = mockStore({
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 = mockStore({
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 = mockStore({
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 = mockStore({
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,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 { render } from "@testing-library/react-native";
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 = configureStore()({
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 } = render(
45
- <Provider store={store}>
46
- <WrappedComponent />
47
- </Provider>
42
+ const { getByText, getByTestId } = renderWithProviders(
43
+ <WrappedComponent />,
44
+ store
48
45
  );
49
46
 
50
47
  expect(getByText("I'm a component")).toBeTruthy();
@@ -10,6 +10,15 @@ import { appLifeCycleManager } from "../";
10
10
 
11
11
  const mock_actions = {};
12
12
 
13
+ jest.mock(
14
+ "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage",
15
+ () => ({
16
+ sessionStorage: {
17
+ getAllItems: jest.fn(() => Promise.resolve(mocked_items)),
18
+ },
19
+ })
20
+ );
21
+
13
22
  jest.mock("@applicaster/zapp-react-native-redux/AppData", () => ({
14
23
  loadAppData: jest.fn(() => () => Promise.resolve()),
15
24
  }));
package/App/index.tsx CHANGED
@@ -76,7 +76,10 @@ const App = ({
76
76
  <LoadingOverlay />
77
77
  </ErrorBoundary>
78
78
  <LogicAggregatorContainer
79
- components={[InteractionManager, ApplyScreenHooks]}
79
+ components={React.useMemo(
80
+ () => [InteractionManager, ApplyScreenHooks],
81
+ [InteractionManager, ApplyScreenHooks]
82
+ )}
80
83
  />
81
84
  </AppContainer>
82
85
  </SafeAreaProvider>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "14.0.0-alpha.9119252693",
3
+ "version": "14.0.0-alpha.9203091422",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,13 +28,13 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "14.0.0-alpha.9119252693",
32
- "@applicaster/quick-brick-core-plugins": "14.0.0-alpha.9119252693",
33
- "@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.9119252693",
34
- "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.9119252693",
35
- "@applicaster/zapp-react-native-redux": "14.0.0-alpha.9119252693",
36
- "@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.9119252693",
37
- "@applicaster/zapp-react-native-utils": "14.0.0-alpha.9119252693",
31
+ "@applicaster/applicaster-types": "14.0.0-alpha.9203091422",
32
+ "@applicaster/quick-brick-core-plugins": "14.0.0-alpha.9203091422",
33
+ "@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.9203091422",
34
+ "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.9203091422",
35
+ "@applicaster/zapp-react-native-redux": "14.0.0-alpha.9203091422",
36
+ "@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.9203091422",
37
+ "@applicaster/zapp-react-native-utils": "14.0.0-alpha.9203091422",
38
38
  "atob": "^2.1.2",
39
39
  "axios": "^0.28.0",
40
40
  "btoa": "^1.2.1",
@@ -42,7 +42,7 @@
42
42
  "md5": "^2.3.0",
43
43
  "promise": "^8.3.0",
44
44
  "query-string": "7.1.3",
45
- "react-redux": "^7.2.1",
45
+ "react-redux": "9.2.0",
46
46
  "redux": "^4.0.4",
47
47
  "reselect": "^4.0.0",
48
48
  "url": "^0.11.0",
@@ -61,7 +61,6 @@
61
61
  "react-native": "*",
62
62
  "react-native-fs": "*",
63
63
  "react-native-linear-gradient": "*",
64
- "react-native-safe-area-context": "*",
65
64
  "react-native-svg": "*",
66
65
  "react-native-webview": "*",
67
66
  "uglify-js": "*",
@@ -19,7 +19,7 @@
19
19
  * @param {React.ComponentType<any>} App component to start
20
20
  */
21
21
  export function renderZappApp(options) {
22
- const { App, AppRegistry, appMountId } = options;
22
+ const { App, AppRegistry, appMountId, mode } = options;
23
23
 
24
24
  if (!App) {
25
25
  throw new Error("No App Component provided, nothing to render");
@@ -37,6 +37,7 @@ export function renderZappApp(options) {
37
37
  if (appMountId) {
38
38
  AppRegistry.runApplication("QuickBrickApp", {
39
39
  rootTag: document.getElementById(appMountId),
40
+ mode,
40
41
  });
41
42
  }
42
43
  }