@applicaster/zapp-react-native-utils 13.0.0-rc.16 → 13.0.0-rc.17
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 +12 -1
- package/alertUtils/alert.ts +148 -0
- package/alertUtils/index.ts +1 -148
- package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +7 -7
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +186 -186
- package/appUtils/contextKeysManager/contextResolver.ts +73 -0
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +6 -6
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +1 -1
- package/appUtils/orientationHelper.ts +1 -1
- package/appUtils/playerManager/playerNative.ts +1 -1
- package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
- package/manifestUtils/__tests__/createConfig.test.js +18 -16
- package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
- package/navigationUtils/__tests__/itemTypes.test.js +2 -2
- package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
- package/package.json +3 -2
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
- package/reactHooks/cell-click/__tests__/index.test.js +5 -2
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
- package/reactHooks/feed/usePipesCacheReset.ts +5 -5
- package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
- package/reactHooks/layout/__tests__/index.test.tsx +10 -10
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
- package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
- package/reactHooks/navigation/index.ts +22 -214
- package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
- package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
- package/reactHooks/navigation/useGetTabBarHeight.ts +12 -0
- package/reactHooks/navigation/useIsScreenActive.ts +17 -0
- package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
- package/reactHooks/navigation/useNavigationType.ts +15 -0
- package/reactHooks/navigation/usePathname.ts +4 -0
- package/reactHooks/navigation/useRoute.ts +100 -0
- package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
- package/reactHooks/player/__tests__/useAutoSeek._test.tsx +2 -3
- package/reactUtils/__tests__/reactUtils.test.js +10 -28
- package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +19 -19
- package/reactUtils/createContext/__tests__/__snapshots__/index.test.js.snap +2 -2
- package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -3
- package/reactUtils/createContext/__tests__/helpers.test.js +8 -8
- package/theme/__mocks__/index.ts +4 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
jest.mock("create-react-ref/lib/createRef", () => jest.fn());
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import * as helpers from "../helpers";
|
|
4
3
|
|
|
@@ -8,13 +7,7 @@ import {
|
|
|
8
7
|
componentDidMount,
|
|
9
8
|
} from "./fixtures";
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
attachLifeCycleMethods,
|
|
13
|
-
createReactRef,
|
|
14
|
-
mergeChildrenProps,
|
|
15
|
-
} = require("../index");
|
|
16
|
-
|
|
17
|
-
const createRef = require("create-react-ref/lib/createRef");
|
|
10
|
+
import { attachLifeCycleMethods, createReactRef, mergeChildrenProps } from "..";
|
|
18
11
|
|
|
19
12
|
describe("attachLifeCycleMethods", () => {
|
|
20
13
|
let addLifeCycleMethodsSpy;
|
|
@@ -50,30 +43,19 @@ describe("attachLifeCycleMethods", () => {
|
|
|
50
43
|
|
|
51
44
|
describe("createReactRef", () => {
|
|
52
45
|
it("calls the React.createRef function if it exists", () => {
|
|
53
|
-
jest.
|
|
54
|
-
|
|
55
|
-
jest.doMock("react", () => ({
|
|
56
|
-
...jest.requireActual("react"),
|
|
57
|
-
createRef: jest.fn(),
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
const React = require("react");
|
|
46
|
+
jest.clearAllMocks();
|
|
61
47
|
|
|
62
|
-
createReactRef();
|
|
63
|
-
expect(
|
|
64
|
-
expect(createRef).not.toHaveBeenCalled();
|
|
48
|
+
const ref = createReactRef();
|
|
49
|
+
expect(ref).toHaveProperty("current");
|
|
65
50
|
});
|
|
66
51
|
|
|
67
52
|
it("calls the polyfill if React.createRef doesn't exist", () => {
|
|
68
|
-
jest.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
createReactRef();
|
|
76
|
-
expect(createRef).toHaveBeenCalled();
|
|
53
|
+
jest.clearAllMocks();
|
|
54
|
+
const originalCreateRef = React.createRef;
|
|
55
|
+
React.createRef = undefined;
|
|
56
|
+
const ref = createReactRef();
|
|
57
|
+
expect(ref).toHaveProperty("current");
|
|
58
|
+
React.createRef = originalCreateRef;
|
|
77
59
|
});
|
|
78
60
|
});
|
|
79
61
|
|
|
@@ -1,104 +1,104 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 1`] = `
|
|
4
|
-
|
|
4
|
+
{
|
|
5
5
|
"bar": "bar",
|
|
6
6
|
"foo": "foo",
|
|
7
7
|
}
|
|
8
8
|
`;
|
|
9
9
|
|
|
10
10
|
exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 2`] = `
|
|
11
|
-
|
|
11
|
+
{
|
|
12
12
|
"bar": "bar",
|
|
13
13
|
"foo": "invalid foo",
|
|
14
14
|
}
|
|
15
15
|
`;
|
|
16
16
|
|
|
17
17
|
exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 3`] = `
|
|
18
|
-
|
|
18
|
+
{
|
|
19
19
|
"bar": "invalid bar",
|
|
20
20
|
"foo": "invalid foo",
|
|
21
21
|
}
|
|
22
22
|
`;
|
|
23
23
|
|
|
24
24
|
exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 4`] = `
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
[
|
|
26
|
+
[
|
|
27
27
|
[Function],
|
|
28
28
|
],
|
|
29
|
-
|
|
29
|
+
[
|
|
30
30
|
[Function],
|
|
31
31
|
],
|
|
32
32
|
]
|
|
33
33
|
`;
|
|
34
34
|
|
|
35
35
|
exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 1`] = `
|
|
36
|
-
|
|
36
|
+
{
|
|
37
37
|
"bar": "bar",
|
|
38
38
|
"foo": "foo",
|
|
39
39
|
}
|
|
40
40
|
`;
|
|
41
41
|
|
|
42
42
|
exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 2`] = `
|
|
43
|
-
|
|
43
|
+
{
|
|
44
44
|
"bar": "bar",
|
|
45
45
|
"foo": "new foo",
|
|
46
46
|
}
|
|
47
47
|
`;
|
|
48
48
|
|
|
49
49
|
exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 3`] = `
|
|
50
|
-
|
|
50
|
+
{
|
|
51
51
|
"bar": "new bar",
|
|
52
52
|
"foo": "new foo",
|
|
53
53
|
}
|
|
54
54
|
`;
|
|
55
55
|
|
|
56
56
|
exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 4`] = `
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
[
|
|
58
|
+
[
|
|
59
59
|
[Function],
|
|
60
60
|
],
|
|
61
|
-
|
|
61
|
+
[
|
|
62
62
|
[Function],
|
|
63
63
|
],
|
|
64
64
|
]
|
|
65
65
|
`;
|
|
66
66
|
|
|
67
67
|
exports[`createContextSetters when state validator is provided skips the update if the new value is the same as the previous one 1`] = `
|
|
68
|
-
|
|
68
|
+
{
|
|
69
69
|
"bar": "bar",
|
|
70
70
|
"foo": "new foo",
|
|
71
71
|
}
|
|
72
72
|
`;
|
|
73
73
|
|
|
74
74
|
exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 1`] = `
|
|
75
|
-
|
|
75
|
+
{
|
|
76
76
|
"bar": "bar",
|
|
77
77
|
"foo": "foo",
|
|
78
78
|
}
|
|
79
79
|
`;
|
|
80
80
|
|
|
81
81
|
exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 2`] = `
|
|
82
|
-
|
|
82
|
+
{
|
|
83
83
|
"bar": "bar",
|
|
84
84
|
"foo": "foo",
|
|
85
85
|
}
|
|
86
86
|
`;
|
|
87
87
|
|
|
88
88
|
exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 3`] = `
|
|
89
|
-
|
|
89
|
+
{
|
|
90
90
|
"bar": "bar",
|
|
91
91
|
"foo": "foo",
|
|
92
92
|
}
|
|
93
93
|
`;
|
|
94
94
|
|
|
95
95
|
exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 4`] = `
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
[
|
|
97
|
+
[
|
|
98
98
|
"trying to invoke setFoo with invalid foo - but it was rejected by the state validator
|
|
99
99
|
skipping context update",
|
|
100
100
|
],
|
|
101
|
-
|
|
101
|
+
[
|
|
102
102
|
"trying to invoke setBar with invalid bar - but it was rejected by the state validator
|
|
103
103
|
skipping context update",
|
|
104
104
|
],
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`createContext - when React has the new context API returns the components and the decorators 1`] = `
|
|
4
|
-
|
|
4
|
+
{
|
|
5
5
|
"Consumer": [MockFunction],
|
|
6
6
|
"Provider": [MockFunction],
|
|
7
|
-
"ReactContext":
|
|
7
|
+
"ReactContext": {
|
|
8
8
|
"Consumer": [MockFunction],
|
|
9
9
|
"Provider": [MockFunction],
|
|
10
10
|
},
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`createProvider creates a context Provider component 1`] = `
|
|
4
4
|
<mockConstructor
|
|
5
5
|
value={
|
|
6
|
-
|
|
6
|
+
{
|
|
7
7
|
"context": "initialValue",
|
|
8
8
|
"otherContext": "otherValue",
|
|
9
9
|
"setContext": [Function],
|
|
@@ -18,11 +18,11 @@ exports[`createProvider creates a context Provider component 1`] = `
|
|
|
18
18
|
`;
|
|
19
19
|
|
|
20
20
|
exports[`createProvider creates a context Provider component 2`] = `
|
|
21
|
-
|
|
21
|
+
{
|
|
22
22
|
"children": <MockChild
|
|
23
23
|
context="context"
|
|
24
24
|
/>,
|
|
25
|
-
"value":
|
|
25
|
+
"value": {
|
|
26
26
|
"context": "initialValue",
|
|
27
27
|
"otherContext": "otherValue",
|
|
28
28
|
"setContext": [Function],
|
|
@@ -9,13 +9,13 @@ function stateValidator({ property, value }) {
|
|
|
9
9
|
);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const mockLogger = {
|
|
13
13
|
warning: jest.fn(),
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
jest.mock("../../logger", () => ({
|
|
17
17
|
reactUtilsLogger: {
|
|
18
|
-
addSubsystem: jest.fn(() =>
|
|
18
|
+
addSubsystem: jest.fn(() => mockLogger),
|
|
19
19
|
},
|
|
20
20
|
}));
|
|
21
21
|
|
|
@@ -62,7 +62,7 @@ describe("createContextSetters", () => {
|
|
|
62
62
|
beforeEach(() => {
|
|
63
63
|
instance.resetInitialState();
|
|
64
64
|
setStateSpy.mockClear();
|
|
65
|
-
|
|
65
|
+
mockLogger.warning.mockClear();
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
it("adds all properties and setters to the component", () => {
|
|
@@ -83,7 +83,7 @@ describe("createContextSetters", () => {
|
|
|
83
83
|
|
|
84
84
|
expect(setStateSpy).toHaveBeenCalledTimes(2);
|
|
85
85
|
expect(setStateSpy.mock.calls).toMatchSnapshot();
|
|
86
|
-
expect(
|
|
86
|
+
expect(mockLogger.warning).not.toHaveBeenCalled();
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
it("skips the update if the state validator doesn't pass", () => {
|
|
@@ -96,8 +96,8 @@ describe("createContextSetters", () => {
|
|
|
96
96
|
expect(instance.state).toMatchSnapshot();
|
|
97
97
|
|
|
98
98
|
expect(setStateSpy).not.toHaveBeenCalled();
|
|
99
|
-
expect(
|
|
100
|
-
expect(
|
|
99
|
+
expect(mockLogger.warning).toHaveBeenCalledTimes(2);
|
|
100
|
+
expect(mockLogger.warning.mock.calls).toMatchSnapshot();
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
it("skips the update if the new value is the same as the previous one", () => {
|
|
@@ -131,7 +131,7 @@ describe("createContextSetters", () => {
|
|
|
131
131
|
|
|
132
132
|
afterEach(() => {
|
|
133
133
|
setStateSpy.mockClear();
|
|
134
|
-
|
|
134
|
+
mockLogger.warning.mockClear();
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
it("adds all properties and setters to the component", () => {
|
|
@@ -152,7 +152,7 @@ describe("createContextSetters", () => {
|
|
|
152
152
|
|
|
153
153
|
expect(setStateSpy).toHaveBeenCalledTimes(2);
|
|
154
154
|
expect(setStateSpy.mock.calls).toMatchSnapshot();
|
|
155
|
-
expect(
|
|
155
|
+
expect(mockLogger.warning).not.toHaveBeenCalled();
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
158
|
});
|
package/theme/__mocks__/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
1
3
|
export const themeMock = {
|
|
2
4
|
screen_padding_top: 20,
|
|
3
5
|
screen_padding_bottom: 48,
|
|
@@ -17,3 +19,5 @@ export const themeMock = {
|
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
export const useTheme = jest.fn().mockReturnValue(themeMock);
|
|
22
|
+
|
|
23
|
+
export const ThemeContext = React.createContext(themeMock);
|