@applicaster/quick-brick-core 13.0.0-alpha.4863201005 → 13.0.0-alpha.4951885994
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/DeepLinking/URLSchemeListener/__tests__/URLSchemeListener.test.js +40 -0
- package/App/DeepLinking/URLSchemeListener/index.tsx +1 -1
- package/App/ErrorBoundary/__tests__/errorBoundary.test.jsx +232 -0
- package/App/ErrorBoundary/__tests__/store.test.js +143 -0
- package/App/ErrorBoundary/index.tsx +45 -21
- package/App/ErrorBoundary/store.ts +26 -0
- package/App/ModalProvider/ModalBottomSheet/index.tsx +4 -2
- package/App/ModalProvider/index.tsx +3 -4
- package/App/NetworkStatusProvider/utils.ts +0 -1
- package/App/StoreConnector/__tests__/storeConnector.test.js +17 -11
- package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.tsx +146 -0
- package/App/appLifeCycleManager/index.tsx +4 -4
- package/App/remoteContextReloader/__tests__/remoteContextReloader.test.js +11 -21
- package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +14 -0
- package/createZappApp/__tests__/__snapshots__/createZappApp.test.js.snap +5 -128
- package/createZappApp/__tests__/createZappApp.test.js +7 -20
- package/defaults/__tests__/defaults.test.js +3 -4
- package/package.json +10 -13
- package/App/DeepLinking/URLSchemeListener/__tests__/URLSchemeListenerTest.js +0 -177
- package/App/ErrorBoundary/__tests__/__snapshots__/errorBoundary.test.js.snap +0 -9
- package/App/ErrorBoundary/__tests__/errorBoundary.test.js +0 -72
- package/App/StoreConnector/__tests__/__snapshots__/storeConnector.test.js.snap +0 -35
- package/App/appLifeCycleManager/__tests__/__snapshots__/appLifeCycleManager.test.js.snap +0 -30
- package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.js +0 -134
- package/App/remoteContextReloader/__tests__/__snapshots__/remoteContextReloader.test.js.snap +0 -43
|
@@ -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,72 +0,0 @@
|
|
|
1
|
-
import 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 { ErrorBoundary } from "../index";
|
|
7
|
-
|
|
8
|
-
const TestComponent = ({ error }: { error: any }) => {
|
|
9
|
-
if (error) {
|
|
10
|
-
throw new Error("error !!");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<View>
|
|
15
|
-
<Text>all is good</Text>
|
|
16
|
-
</View>
|
|
17
|
-
);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const errorState = {
|
|
21
|
-
hasError: true,
|
|
22
|
-
error: new Error("oh no"),
|
|
23
|
-
info: { componentStack: "error at ... \n ..." },
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
describe("<ErrorBoundary />", () => {
|
|
27
|
-
describe("when there is no error", () => {
|
|
28
|
-
const wrapper = shallow(
|
|
29
|
-
<ErrorBoundary>
|
|
30
|
-
<TestComponent />
|
|
31
|
-
</ErrorBoundary>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
it("renders correctly", () => {
|
|
35
|
-
expect(shallowToJson(wrapper)).toMatchSnapshot();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe("When an error is caught", () => {
|
|
40
|
-
const _consoleLog = console.log; // eslint-disable-line no-console
|
|
41
|
-
|
|
42
|
-
const didCatchSpy = jest.spyOn(
|
|
43
|
-
ErrorBoundary.prototype,
|
|
44
|
-
"componentDidCatch"
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const wrapper = shallow(
|
|
48
|
-
<ErrorBoundary>
|
|
49
|
-
<TestComponent error />
|
|
50
|
-
</ErrorBoundary>
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
wrapper.setState(errorState);
|
|
54
|
-
|
|
55
|
-
beforeAll(() => {
|
|
56
|
-
console.log = jest.fn(); // eslint-disable-line no-console
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
afterAll(() => {
|
|
60
|
-
console.log = _consoleLog; // eslint-disable-line no-console
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it.skip("the componentDidCatch method is called", () => {
|
|
64
|
-
// a current bug with enzyme doesn't allow this to be tested
|
|
65
|
-
expect(didCatchSpy).toHaveBeenCalled();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("renders correctly", () => {
|
|
69
|
-
expect(shallowToJson(wrapper)).toMatchSnapshot();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -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
|
-
{
|
|
7
|
-
"bundleIdentifier": "com.app.test",
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
components={
|
|
11
|
-
{
|
|
12
|
-
"grid": [MockFunction],
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
dispatch={[Function]}
|
|
16
|
-
rivers={
|
|
17
|
-
{
|
|
18
|
-
"A123": {
|
|
19
|
-
"id": "A123",
|
|
20
|
-
"name": "home",
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
store={
|
|
25
|
-
{
|
|
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
|
-
[
|
|
21
|
-
[
|
|
22
|
-
{
|
|
23
|
-
"data": {
|
|
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 mockLogger = {
|
|
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(() => mockLogger),
|
|
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.doMock("@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
|
-
mockLogger.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(mockLogger.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
|
-
});
|
package/App/remoteContextReloader/__tests__/__snapshots__/remoteContextReloader.test.js.snap
DELETED
|
@@ -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
|
-
{
|
|
7
|
-
"runtimeConfigurationUrls": {
|
|
8
|
-
"foo": "bar",
|
|
9
|
-
},
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
dispatch={[MockFunction]}
|
|
13
|
-
plugins={[]}
|
|
14
|
-
/>
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
exports[`remoteContextReloader when in __DEV__ doesn't invoke the context reloader 1`] = `
|
|
18
|
-
<Component
|
|
19
|
-
appSettings={
|
|
20
|
-
{
|
|
21
|
-
"runtimeConfigurationUrls": {
|
|
22
|
-
"foo": "bar",
|
|
23
|
-
},
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
dispatch={[MockFunction]}
|
|
27
|
-
plugins={[]}
|
|
28
|
-
/>
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
exports[`remoteContextReloader when not in __DEV__ invokes the context reloader 1`] = `
|
|
32
|
-
<Component
|
|
33
|
-
appSettings={
|
|
34
|
-
{
|
|
35
|
-
"runtimeConfigurationUrls": {
|
|
36
|
-
"foo": "bar",
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
dispatch={[MockFunction]}
|
|
41
|
-
plugins={[]}
|
|
42
|
-
/>
|
|
43
|
-
`;
|