@applicaster/zapp-react-native-utils 13.0.0-alpha.5033140607 → 13.0.0-alpha.5153173047
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/README.md +0 -10
- package/actionsExecutor/ActionExecutor.ts +16 -9
- package/actionsExecutor/ActionExecutorContext.tsx +74 -9
- package/alertUtils/alert.ts +148 -0
- package/alertUtils/index.ts +1 -148
- package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
- package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
- package/analyticsUtils/currentScreenProperities.ts +6 -4
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
- package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
- package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
- package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
- package/appUtils/HooksManager/{index.js → index.ts} +122 -113
- package/appUtils/HooksManager/types.ts +119 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/accessibilityManager/index.ts +42 -1
- package/appUtils/contextKeysManager/contextResolver.ts +77 -0
- package/appUtils/contextKeysManager/index.ts +2 -2
- package/appUtils/contextKeysManager/utils/index.ts +2 -1
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +7 -6
- package/appUtils/focusManager/index.ts +100 -74
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
- package/appUtils/focusManager/utils/enums.ts +4 -0
- package/appUtils/focusManagerAux/utils/index.ts +4 -3
- package/appUtils/{index.js → index.ts} +1 -1
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
- package/appUtils/keyCodes/{index.js → index.ts} +13 -7
- package/appUtils/keyCodes/keys/index.ts +3 -0
- package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
- package/appUtils/keyCodes/keys/keys.android.ts +18 -0
- package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
- package/appUtils/keyCodes/keys/keys.ts +15 -0
- package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -0
- package/appUtils/keyCodes/keysByPlatform.ts +8 -0
- package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
- package/appUtils/orientationHelper.ts +1 -2
- package/appUtils/platform/const.ts +14 -0
- package/appUtils/platform/platformUtils.ts +47 -18
- package/appUtils/playerManager/index.ts +1 -1
- package/appUtils/playerManager/player.ts +19 -7
- package/appUtils/playerManager/playerNative.ts +3 -2
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
- package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
- package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
- package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
- package/equalUtils/index.ts +49 -30
- package/focusManager/FocusManager.ts +11 -1
- package/focusManager/index.ts +41 -4
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
- package/functionUtils/index.ts +36 -19
- package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
- package/idleUtils/index.ts +1 -1
- package/idleUtils/withTimeout.ts +15 -2
- package/logger/const.ts +9 -67
- package/manifestUtils/__tests__/createConfig.test.js +16 -16
- package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
- package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
- package/modalState/index.ts +1 -5
- 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/navigationUtils/index.ts +17 -8
- package/numberUtils/index.ts +7 -5
- package/package.json +5 -9
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +6 -8
- package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
- package/reactHooks/cell-click/__tests__/index.test.js +10 -2
- package/reactHooks/cell-click/index.ts +7 -1
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
- package/reactHooks/feed/useFeedLoader.tsx +1 -1
- 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/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
- package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
- package/reactHooks/navigation/index.ts +35 -236
- package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
- package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
- package/reactHooks/navigation/useGetTabBarHeight.ts +10 -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/useProfilerLogging.ts +15 -0
- package/reactHooks/navigation/useRoute.ts +100 -0
- package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
- package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
- package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
- package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
- package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
- package/reactHooks/player/const.ts +0 -4
- package/reactHooks/player/index.ts +0 -6
- package/reactHooks/state/useRefWithInitialValue.ts +14 -0
- package/reactHooks/state/useStateFromSubscribe.ts +23 -0
- package/reactHooks/usePluginConfiguration.ts +1 -1
- package/reactHooks/useSubscriberFor.ts +4 -3
- package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
- package/reactUtils/__tests__/reactUtils.test.js +1 -37
- package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
- package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +13 -79
- package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +2 -2
- package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
- package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
- package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
- package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
- package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
- package/reactUtils/createContext/__tests__/provider.test.js +4 -6
- package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
- package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
- package/reactUtils/createContext/helpers.ts +6 -1
- package/reactUtils/createContext/index.ts +11 -25
- package/reactUtils/index.ts +0 -25
- package/screenState/index.ts +24 -10
- package/testUtils/index.tsx +0 -10
- package/theme/__mocks__/index.ts +4 -0
- package/theme/index.ts +1 -1
- package/time/Timer.ts +5 -2
- package/types.ts +1 -0
- package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
- package/appUtils/keyCodes/keys.ios.js +0 -46
- package/reactHooks/player/useAutoSeek.tsx +0 -87
- package/reactHooks/player/useSeek.tsx +0 -66
- package/reactHooks/player/useTapSeek.tsx +0 -58
- package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
- /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
- /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
- /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
- /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
- /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
- /package/domUtils/{logger.js → logger.ts} +0 -0
- /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
|
@@ -4,9 +4,10 @@ import { subscriber } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
|
4
4
|
const subscriberObjects = Object.create({});
|
|
5
5
|
|
|
6
6
|
interface UseSubscriberFor {
|
|
7
|
-
(
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
(
|
|
8
|
+
eventName: string,
|
|
9
|
+
handler?: (...args: unknown[]) => void
|
|
10
|
+
): (...args: unknown[]) => ReturnType<typeof subscriber>;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`addLifeCycleMethods attaches the lifecycle method to the component 1`] = `
|
|
3
|
+
exports[`reactUtils helpers addLifeCycleMethods attaches the lifecycle method to the component 1`] = `
|
|
4
4
|
<View>
|
|
5
5
|
<Text>
|
|
6
6
|
I'm a class component
|
|
@@ -8,7 +8,7 @@ exports[`addLifeCycleMethods attaches the lifecycle method to the component 1`]
|
|
|
8
8
|
</View>
|
|
9
9
|
`;
|
|
10
10
|
|
|
11
|
-
exports[`attachMethodToPrototype attaches a lifecycle method to the component's prototype 1`] = `
|
|
11
|
+
exports[`reactUtils helpers attachMethodToPrototype attaches a lifecycle method to the component's prototype 1`] = `
|
|
12
12
|
<View>
|
|
13
13
|
<Text>
|
|
14
14
|
I'm a class component
|
|
@@ -16,6 +16,18 @@ exports[`attachMethodToPrototype attaches a lifecycle method to the component's
|
|
|
16
16
|
</View>
|
|
17
17
|
`;
|
|
18
18
|
|
|
19
|
-
exports[`attachMethodToPrototype preserves any existing lifecycle method 1`] =
|
|
19
|
+
exports[`reactUtils helpers attachMethodToPrototype preserves any existing lifecycle method 1`] = `
|
|
20
|
+
<View>
|
|
21
|
+
<Text>
|
|
22
|
+
I'm a stateless component
|
|
23
|
+
</Text>
|
|
24
|
+
</View>
|
|
25
|
+
`;
|
|
20
26
|
|
|
21
|
-
exports[`wrapInClass wraps the stateless component in a class 1`] =
|
|
27
|
+
exports[`reactUtils helpers wrapInClass wraps the stateless component in a class 1`] = `
|
|
28
|
+
<View>
|
|
29
|
+
<Text>
|
|
30
|
+
I'm a stateless component
|
|
31
|
+
</Text>
|
|
32
|
+
</View>
|
|
33
|
+
`;
|
|
@@ -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, mergeChildrenProps } from "..";
|
|
18
11
|
|
|
19
12
|
describe("attachLifeCycleMethods", () => {
|
|
20
13
|
let addLifeCycleMethodsSpy;
|
|
@@ -48,35 +41,6 @@ describe("attachLifeCycleMethods", () => {
|
|
|
48
41
|
});
|
|
49
42
|
});
|
|
50
43
|
|
|
51
|
-
describe("createReactRef", () => {
|
|
52
|
-
it("calls the React.createRef function if it exists", () => {
|
|
53
|
-
jest.resetModules();
|
|
54
|
-
|
|
55
|
-
jest.doMock("react", () => ({
|
|
56
|
-
...jest.requireActual("react"),
|
|
57
|
-
createRef: jest.fn(),
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
const React = require("react");
|
|
61
|
-
|
|
62
|
-
createReactRef();
|
|
63
|
-
expect(React.createRef).toHaveBeenCalled();
|
|
64
|
-
expect(createRef).not.toHaveBeenCalled();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("calls the polyfill if React.createRef doesn't exist", () => {
|
|
68
|
-
jest.resetModules();
|
|
69
|
-
|
|
70
|
-
jest.doMock("react", () => ({
|
|
71
|
-
...jest.requireActual("react"),
|
|
72
|
-
createRef: undefined,
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
|
-
createReactRef();
|
|
76
|
-
expect(createRef).toHaveBeenCalled();
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
44
|
describe("mergeChildrenProps", () => {
|
|
81
45
|
it("returns the cloned children with the merged props", () => {
|
|
82
46
|
const Egg = () => React.createElement("Egg");
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { shallowToJson } from "enzyme-to-json";
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
5
|
isClassComponent,
|
|
@@ -20,98 +19,100 @@ import {
|
|
|
20
19
|
} from "./fixtures";
|
|
21
20
|
|
|
22
21
|
describe("reactUtils helpers", () => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
describe("isNilOrEmpty", () => {
|
|
23
|
+
it("should return correct output", () => {
|
|
24
|
+
expect(isNilOrEmpty).toBeDefined();
|
|
25
|
+
expect(isNilOrEmpty(null)).toBeTruthy();
|
|
26
|
+
expect(isNilOrEmpty(undefined)).toBeTruthy();
|
|
27
|
+
expect(isNilOrEmpty("")).toBeTruthy();
|
|
28
|
+
expect(isNilOrEmpty([])).toBeTruthy();
|
|
29
|
+
});
|
|
29
30
|
});
|
|
30
|
-
});
|
|
31
31
|
|
|
32
|
-
describe("isClassComponent", () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
describe("isClassComponent", () => {
|
|
33
|
+
it("returns true if the component is a class component", () => {
|
|
34
|
+
expect(isClassComponent(ClassComponent)).toBe(true);
|
|
35
|
+
});
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
it("returns false otherwise", () => {
|
|
38
|
+
expect(isClassComponent(StatelessComponent)).toBe(false);
|
|
39
|
+
});
|
|
39
40
|
});
|
|
40
|
-
});
|
|
41
41
|
|
|
42
|
-
describe("attachMethodToPrototype", () => {
|
|
43
|
-
|
|
42
|
+
describe("attachMethodToPrototype", () => {
|
|
43
|
+
const initialWrapper = render(<ClassComponent />);
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
COMPONENT_DID_MOUNT_METHOD
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
afterEach(() => {
|
|
50
|
-
componentDidMount.mockClear();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("attaches a lifecycle method to the component's prototype", () => {
|
|
54
|
-
const NewComponent = attachMethodToPrototype(ClassComponent)(
|
|
55
|
-
componentDidMount,
|
|
45
|
+
expect(initialWrapper.toJSON()).not.toHaveProperty(
|
|
56
46
|
COMPONENT_DID_MOUNT_METHOD
|
|
57
47
|
);
|
|
58
48
|
|
|
59
|
-
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
componentDidMount.mockClear();
|
|
51
|
+
});
|
|
60
52
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
it("attaches a lifecycle method to the component's prototype", () => {
|
|
54
|
+
const NewComponent = attachMethodToPrototype(ClassComponent)(
|
|
55
|
+
componentDidMount,
|
|
56
|
+
COMPONENT_DID_MOUNT_METHOD
|
|
57
|
+
);
|
|
65
58
|
|
|
66
|
-
|
|
67
|
-
const NewComponent = attachMethodToPrototype(ComponentWithLifeCycle)(
|
|
68
|
-
componentDidMount,
|
|
69
|
-
COMPONENT_DID_MOUNT_METHOD
|
|
70
|
-
);
|
|
59
|
+
const wrapper = render(<NewComponent />);
|
|
71
60
|
|
|
72
|
-
|
|
61
|
+
expect(wrapper.toJSON(wrapper)).toMatchSnapshot();
|
|
62
|
+
expect(new NewComponent()).toHaveProperty(COMPONENT_DID_MOUNT_METHOD);
|
|
63
|
+
expect(componentDidMount).toHaveBeenCalled();
|
|
64
|
+
});
|
|
73
65
|
|
|
74
|
-
|
|
66
|
+
it("preserves any existing lifecycle method", () => {
|
|
67
|
+
const NewComponent = attachMethodToPrototype(ComponentWithLifeCycle)(
|
|
68
|
+
componentDidMount,
|
|
69
|
+
COMPONENT_DID_MOUNT_METHOD
|
|
70
|
+
);
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
expect(componentDidMount).toHaveBeenCalled();
|
|
78
|
-
expect(existingMethod).toHaveBeenCalled();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
72
|
+
expect(componentDidMount).not.toHaveBeenCalled();
|
|
81
73
|
|
|
82
|
-
|
|
83
|
-
let NewComponent;
|
|
84
|
-
let wrapper;
|
|
74
|
+
const wrapper = render(<NewComponent />);
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
77
|
+
expect(componentDidMount).toHaveBeenCalled();
|
|
78
|
+
expect(existingMethod).toHaveBeenCalled();
|
|
79
|
+
});
|
|
89
80
|
});
|
|
90
81
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
});
|
|
82
|
+
describe("wrapInClass", () => {
|
|
83
|
+
let NewComponent;
|
|
84
|
+
let wrapper;
|
|
96
85
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
beforeEach(() => {
|
|
87
|
+
NewComponent = wrapInClass(StatelessComponent);
|
|
88
|
+
wrapper = render(<NewComponent />);
|
|
89
|
+
});
|
|
100
90
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
91
|
+
it("wraps the stateless component in a class", () => {
|
|
92
|
+
expect(isClassComponent(NewComponent)).toBe(true);
|
|
93
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
94
|
+
});
|
|
104
95
|
});
|
|
105
96
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
97
|
+
describe("addLifeCycleMethods", () => {
|
|
98
|
+
let NewComponent;
|
|
99
|
+
let wrapper;
|
|
109
100
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
101
|
+
beforeEach(() => {
|
|
102
|
+
NewComponent = addLifeCycleMethods({ componentDidMount })(ClassComponent);
|
|
103
|
+
wrapper = render(<NewComponent />);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
afterEach(() => {
|
|
107
|
+
componentDidMount.mockClear();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("attaches the lifecycle method to the component", () => {
|
|
111
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
112
|
+
});
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
it("adds the lifecycle method to the component", () => {
|
|
115
|
+
expect(componentDidMount).toHaveBeenCalled();
|
|
116
|
+
});
|
|
116
117
|
});
|
|
117
118
|
});
|
|
@@ -1,106 +1,40 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 1`] = `
|
|
4
|
-
|
|
3
|
+
exports[`helpers createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 1`] = `
|
|
4
|
+
{
|
|
5
5
|
"bar": "bar",
|
|
6
6
|
"foo": "foo",
|
|
7
7
|
}
|
|
8
8
|
`;
|
|
9
9
|
|
|
10
|
-
exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 2`] = `
|
|
11
|
-
|
|
12
|
-
"bar": "bar",
|
|
13
|
-
"foo": "invalid foo",
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 3`] = `
|
|
18
|
-
Object {
|
|
19
|
-
"bar": "invalid bar",
|
|
20
|
-
"foo": "invalid foo",
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 4`] = `
|
|
25
|
-
Array [
|
|
26
|
-
Array [
|
|
27
|
-
[Function],
|
|
28
|
-
],
|
|
29
|
-
Array [
|
|
30
|
-
[Function],
|
|
31
|
-
],
|
|
32
|
-
]
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 1`] = `
|
|
36
|
-
Object {
|
|
10
|
+
exports[`helpers createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 2`] = `
|
|
11
|
+
{
|
|
37
12
|
"bar": "bar",
|
|
38
13
|
"foo": "foo",
|
|
39
14
|
}
|
|
40
15
|
`;
|
|
41
16
|
|
|
42
|
-
exports[`createContextSetters when state validator is provided calls setState when the setters are called
|
|
43
|
-
|
|
17
|
+
exports[`helpers createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 3`] = `
|
|
18
|
+
{
|
|
44
19
|
"bar": "bar",
|
|
45
|
-
"foo": "
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 3`] = `
|
|
50
|
-
Object {
|
|
51
|
-
"bar": "new bar",
|
|
52
|
-
"foo": "new foo",
|
|
20
|
+
"foo": "foo",
|
|
53
21
|
}
|
|
54
22
|
`;
|
|
55
23
|
|
|
56
|
-
exports[`createContextSetters when state validator is provided calls setState when the setters are called
|
|
57
|
-
|
|
58
|
-
|
|
24
|
+
exports[`helpers createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 4`] = `
|
|
25
|
+
[
|
|
26
|
+
[
|
|
59
27
|
[Function],
|
|
60
28
|
],
|
|
61
|
-
|
|
29
|
+
[
|
|
62
30
|
[Function],
|
|
63
31
|
],
|
|
64
32
|
]
|
|
65
33
|
`;
|
|
66
34
|
|
|
67
|
-
exports[`createContextSetters when state validator is provided skips the update if the new value is the same as the previous one 1`] = `
|
|
68
|
-
|
|
35
|
+
exports[`helpers createContextSetters when state validator is provided skips the update if the new value is the same as the previous one 1`] = `
|
|
36
|
+
{
|
|
69
37
|
"bar": "bar",
|
|
70
38
|
"foo": "new foo",
|
|
71
39
|
}
|
|
72
40
|
`;
|
|
73
|
-
|
|
74
|
-
exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 1`] = `
|
|
75
|
-
Object {
|
|
76
|
-
"bar": "bar",
|
|
77
|
-
"foo": "foo",
|
|
78
|
-
}
|
|
79
|
-
`;
|
|
80
|
-
|
|
81
|
-
exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 2`] = `
|
|
82
|
-
Object {
|
|
83
|
-
"bar": "bar",
|
|
84
|
-
"foo": "foo",
|
|
85
|
-
}
|
|
86
|
-
`;
|
|
87
|
-
|
|
88
|
-
exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 3`] = `
|
|
89
|
-
Object {
|
|
90
|
-
"bar": "bar",
|
|
91
|
-
"foo": "foo",
|
|
92
|
-
}
|
|
93
|
-
`;
|
|
94
|
-
|
|
95
|
-
exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 4`] = `
|
|
96
|
-
Array [
|
|
97
|
-
Array [
|
|
98
|
-
"trying to invoke setFoo with invalid foo - but it was rejected by the state validator
|
|
99
|
-
skipping context update",
|
|
100
|
-
],
|
|
101
|
-
Array [
|
|
102
|
-
"trying to invoke setBar with invalid bar - but it was rejected by the state validator
|
|
103
|
-
skipping context update",
|
|
104
|
-
],
|
|
105
|
-
]
|
|
106
|
-
`;
|
package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap}
RENAMED
|
@@ -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
|
},
|
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`createProvider creates a context Provider component 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"context": "initialValue",
|
|
8
|
-
"otherContext": "otherValue",
|
|
9
|
-
"setContext": [Function],
|
|
10
|
-
"setOtherContext": [Function],
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
>
|
|
14
|
-
<MockChild
|
|
15
|
-
context="context"
|
|
16
|
-
/>
|
|
17
|
-
</mockConstructor>
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
exports[`createProvider creates a context Provider component 2`] = `
|
|
21
|
-
Object {
|
|
22
|
-
"children": <MockChild
|
|
23
|
-
context="context"
|
|
24
|
-
/>,
|
|
25
|
-
"value": Object {
|
|
26
|
-
"context": "initialValue",
|
|
27
|
-
"otherContext": "otherValue",
|
|
28
|
-
"setContext": [Function],
|
|
29
|
-
"setOtherContext": [Function],
|
|
30
|
-
},
|
|
31
|
-
}
|
|
4
|
+
<View>
|
|
5
|
+
context
|
|
6
|
+
</View>
|
|
32
7
|
`;
|