@applicaster/quick-brick-core 13.0.0-alpha.5033140607 → 13.0.0-alpha.5144285042

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 (38) hide show
  1. package/App/ActionsProvider/__tests__/__snapshots__/ActionsProvider.test.js.snap +7 -7
  2. package/App/AssetCache/__tests__/__snapshots__/assetCache.test.ts.snap +103 -103
  3. package/App/AssetCache/__tests__/assetCache.test.ts +3 -2
  4. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/__snapshots__/schemeHandlerHooks.test.ts.snap +1 -1
  5. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +45 -116
  6. package/App/DeepLinking/URLSchemeHandler/__tests__/__snapshots__/URLSchemeHandler.test.tsx.snap +3 -3
  7. package/App/DeepLinking/URLSchemeListener/URLSchemeContextProvider.tsx +30 -3
  8. package/App/DeepLinking/URLSchemeListener/__tests__/URLSchemeListener.test.js +40 -0
  9. package/App/DeepLinking/URLSchemeListener/index.tsx +1 -1
  10. package/App/ErrorBoundary/__tests__/errorBoundary.test.js +20 -37
  11. package/App/LoadingOverlay/LoadingOverlayManager.tsx +27 -0
  12. package/App/LoadingOverlay/index.tsx +49 -0
  13. package/App/LoadingOverlay/useLoadingOverlayVisibility.tsx +18 -0
  14. package/App/ModalProvider/ModalBottomSheet/index.tsx +4 -2
  15. package/App/ModalProvider/index.tsx +3 -4
  16. package/App/NavigationProvider/NavigationProvider.tsx +48 -20
  17. package/App/NavigationProvider/__tests__/__snapshots__/navigationProvider.test.tsx.snap +20 -22
  18. package/App/NavigationProvider/navigator/__tests__/__snapshots__/reducer.test.ts.snap +189 -189
  19. package/App/NetworkStatusProvider/utils.ts +0 -1
  20. package/App/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +2 -2
  21. package/App/StoreConnector/__tests__/storeConnector.test.js +17 -11
  22. package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.tsx +146 -0
  23. package/App/appLifeCycleManager/index.tsx +6 -7
  24. package/App/index.tsx +2 -0
  25. package/App/remoteContextReloader/__tests__/remoteContextReloader.test.js +11 -21
  26. package/App/remoteContextReloader/consts.ts +2 -0
  27. package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +17 -6
  28. package/createZappApp/__tests__/__snapshots__/createZappApp.test.js.snap +5 -128
  29. package/createZappApp/__tests__/createZappApp.test.js +7 -20
  30. package/defaults/__tests__/defaults.test.js +3 -4
  31. package/index.d.ts +1 -1
  32. package/package.json +26 -13
  33. package/App/DeepLinking/URLSchemeListener/__tests__/URLSchemeListenerTest.js +0 -177
  34. package/App/ErrorBoundary/__tests__/__snapshots__/errorBoundary.test.js.snap +0 -9
  35. package/App/StoreConnector/__tests__/__snapshots__/storeConnector.test.js.snap +0 -35
  36. package/App/appLifeCycleManager/__tests__/__snapshots__/appLifeCycleManager.test.js.snap +0 -30
  37. package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.js +0 -134
  38. package/App/remoteContextReloader/__tests__/__snapshots__/remoteContextReloader.test.js.snap +0 -43
@@ -1,177 +0,0 @@
1
- import * as React from "react";
2
- import { View, Text } from "react-native";
3
- import { shallow } from "enzyme";
4
- import { shallowToJson } from "enzyme-to-json";
5
-
6
- import { URLSchemeListener } from "../index";
7
-
8
- const URL = "url";
9
-
10
- const TestComponent = () => (
11
- <View>
12
- <Text>I'm a test component</Text>
13
- </View>
14
- );
15
-
16
- const ReactNative = require("react-native");
17
- const { Linking } = ReactNative;
18
-
19
- const navigator = {
20
- push: jest.fn(),
21
- replace: jest.fn(),
22
- };
23
-
24
- jest.spyOn(console, "warn").mockImplementation(() => jest.fn());
25
-
26
- function clearMocks() {
27
- navigator.push.mockClear();
28
- navigator.replace.mockClear();
29
- console.warn.mockClear(); // eslint-disable-line no-console
30
- Linking.__resetListeners();
31
- Linking.__clearInitialURL();
32
- Linking.addEventListener.mockClear();
33
- Linking.removeEventListener.mockClear();
34
- Linking.getInitialURL.mockClear();
35
- Linking.openURL.mockClear();
36
- }
37
-
38
- describe("URLSchemeHandler", () => {
39
- const getWrapper = (props) =>
40
- shallow(
41
- <URLSchemeListener navigator={navigator} {...props}>
42
- <TestComponent />
43
- </URLSchemeListener>
44
- );
45
-
46
- beforeEach(clearMocks);
47
-
48
- it("renders correctly", () => {
49
- const wrapper = getWrapper();
50
- expect(shallowToJson(wrapper)).toMatchSnapshot();
51
- });
52
-
53
- describe("linking registration", () => {
54
- beforeEach(clearMocks);
55
-
56
- it("registers the listener when the component mounts", () => {
57
- const wrapper = getWrapper();
58
- const instance = wrapper.instance();
59
-
60
- expect(shallowToJson(wrapper)).toMatchSnapshot();
61
-
62
- expect(Linking.addEventListener).toHaveBeenCalledWith(
63
- URL,
64
- instance.handleOpenUrl
65
- );
66
- });
67
-
68
- it("unregisters the listener when the component unmounts", () => {
69
- const wrapper = getWrapper();
70
- const instance = wrapper.instance();
71
- wrapper.unmount();
72
-
73
- expect(Linking.removeEventListener).toHaveBeenCalledWith(
74
- URL,
75
- instance.handleOpenUrl
76
- );
77
- });
78
- });
79
-
80
- describe("initial url", () => {
81
- beforeEach(clearMocks);
82
-
83
- it("tries to get the initial url", () => {
84
- const listenerSpy = jest.fn();
85
- const wrapper = getWrapper({ listenerSpy });
86
-
87
- expect(shallowToJson(wrapper)).toMatchSnapshot();
88
- expect(listenerSpy).toHaveBeenCalledWith("getInitialURL");
89
- expect(Linking.getInitialURL).toHaveBeenCalled();
90
- });
91
-
92
- it("gets the initial url and redirect to it if it exists", async () => {
93
- const listenerSpy = jest.fn();
94
- const url = "http://foo.com";
95
- Linking.__setInitialURL(url);
96
-
97
- const wrapper = getWrapper({ listenerSpy });
98
- const instance = wrapper.instance();
99
-
100
- await instance.componentDidMount();
101
-
102
- expect(listenerSpy).toHaveBeenCalledWith("getInitialURL");
103
-
104
- expect(navigator.replace).toHaveBeenCalledWith(
105
- expect.objectContaining({ url })
106
- );
107
- });
108
-
109
- it("doesn't try to navigate if there is no initial url", async () => {
110
- const listenerSpy = jest.fn();
111
-
112
- const wrapper = getWrapper({ listenerSpy });
113
- const instance = wrapper.instance();
114
- jest.spyOn(instance, "handleOpenUrlError");
115
-
116
- await instance.componentDidMount();
117
-
118
- expect(listenerSpy).toHaveBeenCalledWith("getInitialURL");
119
- expect(listenerSpy).not.toHaveBeenCalledWith("canOpenURL");
120
- expect(navigator.replace).not.toHaveBeenCalled();
121
- });
122
- });
123
-
124
- describe("url scheme handler", () => {
125
- beforeEach(clearMocks);
126
-
127
- it("invokes the listener when a url is triggered", () => {
128
- const listenerSpy = jest.fn();
129
- const wrapper = getWrapper({ listenerSpy });
130
- const url = "http://foo.com";
131
-
132
- Linking.__callUrl(url);
133
-
134
- expect(shallowToJson(wrapper)).toMatchSnapshot();
135
-
136
- expect(listenerSpy).toHaveBeenCalledWith(
137
- "handleOpenUrl",
138
- expect.objectContaining({ url })
139
- );
140
- });
141
-
142
- it("invokes the navigator if a url is triggered and the url is valid", async () => {
143
- const listenerSpy = jest.fn();
144
- const wrapper = getWrapper({ listenerSpy });
145
- const instance = wrapper.instance();
146
- const spy = jest.spyOn(instance, "handleOpenUrl");
147
- const url = "http://foo.com";
148
-
149
- Linking.__callUrl(url);
150
-
151
- await spy;
152
-
153
- expect(navigator.replace).toHaveBeenCalledWith(
154
- expect.objectContaining({ url })
155
- );
156
- });
157
-
158
- it("doesn't invoke the navigator if a url is triggered and the url is undefined", async () => {
159
- const listenerSpy = jest.fn();
160
- const wrapper = getWrapper({ listenerSpy });
161
- const instance = wrapper.instance();
162
- const spy = jest.spyOn(instance, "handleOpenUrl");
163
- const url = undefined; // eslint-disable no-undefined
164
-
165
- Linking.__callUrl(url);
166
-
167
- await spy;
168
-
169
- expect(listenerSpy).toHaveBeenCalledWith(
170
- "handleOpenUrl",
171
- expect.objectContaining({ url })
172
- );
173
-
174
- expect(navigator.replace).not.toHaveBeenCalled();
175
- });
176
- });
177
- });
@@ -1,9 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`<ErrorBoundary /> When an error is caught renders correctly 1`] = `
4
- <ErrorScreen
5
- dismissError={[Function]}
6
- />
7
- `;
8
-
9
- exports[`<ErrorBoundary /> when there is no error renders correctly 1`] = `<TestComponent />`;
@@ -1,35 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`storeConnector passes the props to the component 1`] = `
4
- <Component
5
- appSettings={
6
- Object {
7
- "bundleIdentifier": "com.app.test",
8
- }
9
- }
10
- components={
11
- Object {
12
- "grid": [MockFunction],
13
- }
14
- }
15
- dispatch={[Function]}
16
- rivers={
17
- Object {
18
- "A123": Object {
19
- "id": "A123",
20
- "name": "home",
21
- },
22
- }
23
- }
24
- store={
25
- Object {
26
- "clearActions": [Function],
27
- "dispatch": [Function],
28
- "getActions": [Function],
29
- "getState": [Function],
30
- "replaceReducer": [Function],
31
- "subscribe": [Function],
32
- }
33
- }
34
- />
35
- `;
@@ -1,30 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`appLifeCycleManager runs the loaders, then sends quickBrickReady event 1`] = `
4
- <View>
5
- <Text>
6
- I'm a component
7
- </Text>
8
- </View>
9
- `;
10
-
11
- exports[`appLifeCycleManager sends the quickBrickReady event when a loader doesn't resolves 1`] = `
12
- <View>
13
- <Text>
14
- I'm a component
15
- </Text>
16
- </View>
17
- `;
18
-
19
- exports[`appLifeCycleManager sends the quickBrickReady event when a loader doesn't resolves 2`] = `
20
- Array [
21
- Array [
22
- Object {
23
- "data": Object {
24
- "error": [Error: loading failed],
25
- },
26
- "message": "AppLifeCycleManager: A loading operation failed: loading failed",
27
- },
28
- ],
29
- ]
30
- `;
@@ -1,134 +0,0 @@
1
- import * as React from "react";
2
- import { View, Text } from "react-native";
3
- import { create, act } from "react-test-renderer";
4
-
5
- const Component = () => (
6
- <View>
7
- <Text>I'm a component</Text>
8
- </View>
9
- );
10
-
11
- const logger = {
12
- warning: jest.fn(),
13
- log: jest.fn(),
14
- debug: jest.fn(),
15
- info: jest.fn(),
16
- };
17
-
18
- jest.mock("../../logger", () => ({
19
- coreAppLogger: {
20
- addSubsystem: jest.fn(() => logger),
21
- },
22
- }));
23
-
24
- const QuickBrickManager = {
25
- sendQuickBrickEvent: jest.fn(),
26
- };
27
-
28
- const LOADING_ERROR = new Error("loading failed");
29
-
30
- const appLoader = jest.fn((_dispatch, _getState) => {
31
- if (_getState().shouldFail) return Promise.reject(LOADING_ERROR);
32
-
33
- return Promise.resolve();
34
- });
35
-
36
- const dispatch = jest.fn();
37
-
38
- const state = {
39
- rivers: {},
40
- plugins: {},
41
- appSettings: { runtimeConfigurationUrls: { rivers: "http://rivers.url" } },
42
- };
43
-
44
- const QUICK_BRICK_READY_EVENT = "quickBrickReady";
45
-
46
- const actions = {};
47
-
48
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
49
- useActions: jest.fn(() => ({ actions })),
50
- }));
51
-
52
- const { appLifeCycleManager } = require("../index");
53
-
54
- describe("appLifeCycleManager", () => {
55
- const decorator = appLifeCycleManager(appLoader, QuickBrickManager);
56
-
57
- beforeEach(() => {
58
- logger.warning.mockClear();
59
- appLoader.mockClear();
60
- QuickBrickManager.sendQuickBrickEvent.mockClear();
61
- dispatch.mockClear();
62
- });
63
-
64
- it("returns a function to decorate a component", () => {
65
- expect(decorator).toBeFunction();
66
- });
67
-
68
- it("runs the loaders, then sends quickBrickReady event", (done) => {
69
- const DecoratedComponent = decorator(Component);
70
-
71
- let wrapper;
72
-
73
- const testCallback = () => {
74
- expect(dispatch).toHaveBeenCalledWith(
75
- expect.objectContaining({ type: "SET_APP_READY" })
76
- );
77
-
78
- expect(QuickBrickManager.sendQuickBrickEvent).toHaveBeenCalledWith(
79
- QUICK_BRICK_READY_EVENT
80
- );
81
-
82
- done();
83
- };
84
-
85
- act(() => {
86
- wrapper = create(
87
- <DecoratedComponent
88
- dispatch={dispatch}
89
- {...state}
90
- testCallback={testCallback}
91
- />
92
- );
93
- });
94
-
95
- expect(wrapper.toJSON()).toMatchSnapshot();
96
- expect(appLoader).toHaveBeenCalled();
97
- expect.assertions(4);
98
- });
99
-
100
- it("sends the quickBrickReady event when a loader doesn't resolves", (done) => {
101
- const DecoratedComponent = decorator(Component);
102
-
103
- let wrapper;
104
-
105
- const testCallback = () => {
106
- expect(dispatch).toHaveBeenCalledWith(
107
- expect.objectContaining({ type: "SET_APP_READY" })
108
- );
109
-
110
- expect(QuickBrickManager.sendQuickBrickEvent).toHaveBeenCalledWith(
111
- QUICK_BRICK_READY_EVENT
112
- );
113
-
114
- expect(logger.warning.mock.calls).toMatchSnapshot();
115
-
116
- done();
117
- };
118
-
119
- act(() => {
120
- wrapper = create(
121
- <DecoratedComponent
122
- dispatch={dispatch}
123
- {...state}
124
- shouldFail
125
- testCallback={testCallback}
126
- />
127
- );
128
- });
129
-
130
- expect(wrapper.toJSON()).toMatchSnapshot();
131
- expect(appLoader).toHaveBeenCalled();
132
- expect.assertions(5);
133
- });
134
- });
@@ -1,43 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`remoteContextReloader adds a componentDidMount method 1`] = `
4
- <Component
5
- appSettings={
6
- Object {
7
- "runtimeConfigurationUrls": Object {
8
- "foo": "bar",
9
- },
10
- }
11
- }
12
- dispatch={[MockFunction]}
13
- plugins={Array []}
14
- />
15
- `;
16
-
17
- exports[`remoteContextReloader when in __DEV__ doesn't invoke the context reloader 1`] = `
18
- <Component
19
- appSettings={
20
- Object {
21
- "runtimeConfigurationUrls": Object {
22
- "foo": "bar",
23
- },
24
- }
25
- }
26
- dispatch={[MockFunction]}
27
- plugins={Array []}
28
- />
29
- `;
30
-
31
- exports[`remoteContextReloader when not in __DEV__ invokes the context reloader 1`] = `
32
- <Component
33
- appSettings={
34
- Object {
35
- "runtimeConfigurationUrls": Object {
36
- "foo": "bar",
37
- },
38
- }
39
- }
40
- dispatch={[MockFunction]}
41
- plugins={Array []}
42
- />
43
- `;