@applicaster/zapp-react-native-utils 13.0.0-rc.11 → 13.0.0-rc.111
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 +196 -11
- package/actionsExecutor/consts.ts +4 -0
- 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} +39 -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} +124 -113
- package/appUtils/HooksManager/types.ts +119 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
- package/appUtils/__tests__/allZappLocales.ts +79 -0
- package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
- package/appUtils/accessibilityManager/index.ts +42 -1
- package/appUtils/contextKeysManager/contextResolver.ts +66 -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 +9 -6
- package/appUtils/focusManager/index.ios.ts +14 -4
- package/appUtils/focusManager/index.ts +108 -69
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
- package/appUtils/focusManager/utils/__tests__/findChild.test.ts +35 -0
- package/appUtils/focusManager/utils/enums.ts +4 -0
- package/appUtils/focusManager/utils/index.ts +5 -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/{localizationsHelper.js → localizationsHelper.ts} +31 -0
- package/appUtils/orientationHelper.ts +11 -13
- 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 +42 -18
- package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +11 -7
- package/appUtils/playerManager/playerNative.ts +18 -2
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
- package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
- package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
- package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
- package/componentsUtils/__tests__/isGallery.test.ts +33 -0
- package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
- package/componentsUtils/index.ts +39 -0
- package/dateUtils/index.ts +19 -0
- 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 +14 -2
- package/focusManager/index.ts +23 -4
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
- package/functionUtils/index.ts +61 -19
- package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
- package/idleUtils/index.ts +1 -1
- package/idleUtils/withTimeout.ts +15 -2
- package/index.d.ts +0 -12
- package/localizationUtils/index.ts +5 -10
- package/logger/const.ts +9 -67
- package/manifestUtils/__tests__/createConfig.test.js +16 -16
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +13 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +14 -0
- package/manifestUtils/fonts/index.js +5 -6
- package/manifestUtils/keys.js +27 -2
- 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/__tests__/index.test.ts +51 -0
- package/modalState/index.ts +33 -7
- package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +7 -6
- package/navigationUtils/__tests__/itemTypes.test.js +2 -2
- package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
- package/navigationUtils/index.ts +20 -9
- package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
- package/numberUtils/index.ts +11 -5
- package/package.json +5 -10
- package/playerUtils/configurationGenerator.ts +14 -8
- package/reactHooks/advertising/index.ts +5 -5
- 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/useBatchLoading.ts +9 -11
- package/reactHooks/feed/useFeedLoader.tsx +18 -9
- package/reactHooks/feed/usePipesCacheReset.ts +5 -5
- package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
- 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 +6 -21
- package/reactHooks/navigation/index.ts +41 -240
- 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 +98 -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/screen/__tests__/useScreenBackgroundColor.test.tsx +69 -0
- package/reactHooks/screen/useScreenBackgroundColor.ts +3 -15
- package/reactHooks/state/useRefWithInitialValue.ts +14 -0
- package/reactHooks/state/useStateFromSubscribe.ts +23 -0
- package/reactHooks/useListenEventBusEvent.ts +1 -1
- 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/services/js2native.ts +673 -0
- package/testUtils/index.tsx +0 -10
- package/theme/__mocks__/index.ts +4 -0
- package/theme/index.ts +1 -1
- package/time/BackgroundTimer.ts +55 -0
- package/time/Timer.ts +9 -6
- package/types.ts +1 -0
- package/utils/README.md +30 -0
- package/utils/chunk.ts +5 -0
- package/utils/index.ts +5 -0
- package/utils/times.ts +5 -0
- package/zappFrameworkUtils/localStorageHelper.ts +6 -0
- package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
- package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
- package/zappFrameworkUtils/types.ts +11 -0
- 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/domUtils/{logger.js → logger.ts} +0 -0
- /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
|
@@ -29,7 +29,9 @@ const hooks = (options, otherHook = null) =>
|
|
|
29
29
|
const manager = {
|
|
30
30
|
presentScreenHook: jest.fn(),
|
|
31
31
|
executeHook: jest.fn(),
|
|
32
|
-
|
|
32
|
+
subscriber: {
|
|
33
|
+
invokeHandler: jest.fn(),
|
|
34
|
+
},
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
const getHook = (options, otherHook) =>
|
|
@@ -42,257 +44,267 @@ const getHook = (options, otherHook) =>
|
|
|
42
44
|
function clearMocks() {
|
|
43
45
|
manager.presentScreenHook.mockClear();
|
|
44
46
|
manager.executeHook.mockClear();
|
|
45
|
-
manager.invokeHandler.mockClear();
|
|
47
|
+
manager.subscriber.invokeHandler.mockClear();
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
describe("Hook
|
|
49
|
-
|
|
50
|
+
describe("Hook", () => {
|
|
51
|
+
describe("Hook Properties", () => {
|
|
52
|
+
const hookPlugin = getHook({});
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
beforeEach(clearMocks);
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
it("has all the hook properties", () => {
|
|
57
|
+
expect(hookPlugin).toMatchSnapshot();
|
|
58
|
+
});
|
|
55
59
|
});
|
|
56
|
-
});
|
|
57
60
|
|
|
58
|
-
describe("getModalContainer", () => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
describe("getModalContainer", () => {
|
|
62
|
+
it("returns ModalContainer", () => {
|
|
63
|
+
const ModalContainer = jest.fn();
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
const hookPlugin = getHook({
|
|
66
|
+
general: {},
|
|
67
|
+
module: { ModalContainer },
|
|
68
|
+
});
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
expect(hookPlugin.getModalContainer()).toBe(ModalContainer);
|
|
71
|
+
});
|
|
68
72
|
});
|
|
69
|
-
});
|
|
70
73
|
|
|
71
|
-
describe("isFlowBlocker", () => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
describe("isFlowBlocker", () => {
|
|
75
|
+
it("returns true if the hook is flow blocker", () => {
|
|
76
|
+
const hookPlugin = getHook({ general: { is_flow_blocker: true } });
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
const hookWithoutScreen = getHook({
|
|
79
|
+
general: {},
|
|
80
|
+
module: { isFlowBlocker: () => true },
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(hookPlugin.isFlowBlocker()).toBe(true);
|
|
84
|
+
expect(hookWithoutScreen.isFlowBlocker()).toBe(true);
|
|
78
85
|
});
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
87
|
+
it("returns false otherwise", () => {
|
|
88
|
+
const hookPlugin = getHook({ general: { is_flow_blocker: false } });
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
const hookWithoutScreen = getHook({
|
|
91
|
+
general: {},
|
|
92
|
+
module: { isFlowBlocker: () => false },
|
|
93
|
+
});
|
|
86
94
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
module: { isFlowBlocker: () => false },
|
|
95
|
+
expect(hookPlugin.isFlowBlocker()).toBeFalsy();
|
|
96
|
+
expect(hookWithoutScreen.isFlowBlocker()).toBeFalsy();
|
|
90
97
|
});
|
|
91
|
-
|
|
92
|
-
expect(hookPlugin.isFlowBlocker()).toBeFalsy();
|
|
93
|
-
expect(hookWithoutScreen.isFlowBlocker()).toBeFalsy();
|
|
94
98
|
});
|
|
95
|
-
});
|
|
96
99
|
|
|
97
|
-
describe("skipHook", () => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
describe("skipHook", () => {
|
|
101
|
+
it("returns true if the hooks module skipHook method returns true", () => {
|
|
102
|
+
const hookPlugin = getHook({ module: { skipHook: () => true } });
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
expect(hookPlugin.skipHook()).toBe(true);
|
|
105
|
+
});
|
|
103
106
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
it("returns false otherwise", () => {
|
|
108
|
+
const hookPlugin = getHook({ module: { skipHook: false } });
|
|
109
|
+
const hookPluginWithUndefinedSkipHook = getHook({ module: {} });
|
|
107
110
|
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
expect(hookPlugin.skipHook()).toBeFalsy();
|
|
112
|
+
expect(hookPluginWithUndefinedSkipHook.skipHook()).toBeFalsy();
|
|
113
|
+
});
|
|
110
114
|
});
|
|
111
|
-
});
|
|
112
115
|
|
|
113
|
-
describe("lastHook", () => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
describe("lastHook", () => {
|
|
117
|
+
it("returns true if the current hook is the last one", () => {
|
|
118
|
+
const hookPlugin = getHook({});
|
|
119
|
+
expect(hookPlugin.lastHook).toBe(true);
|
|
120
|
+
});
|
|
118
121
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
it("returns false otherwise", () => {
|
|
123
|
+
const hookPlugin = getHook(
|
|
124
|
+
{},
|
|
125
|
+
{
|
|
126
|
+
screen_id: "B4567",
|
|
127
|
+
type: "general",
|
|
128
|
+
identifier: "some_hook",
|
|
129
|
+
weight: 2,
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
expect(hookPlugin.lastHook).toBe(false);
|
|
134
|
+
});
|
|
131
135
|
});
|
|
132
|
-
});
|
|
133
136
|
|
|
134
|
-
describe("setStateAndNotify", () => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
describe("setStateAndNotify", () => {
|
|
138
|
+
let hookPlugin;
|
|
139
|
+
const args = ["foo", { bar: 42 }];
|
|
137
140
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
beforeEach(() => {
|
|
142
|
+
clearMocks();
|
|
143
|
+
hookPlugin = getHook({});
|
|
144
|
+
});
|
|
142
145
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
it("changes the hook's state", () => {
|
|
147
|
+
hookPlugin.setStateAndNotify(HOOKS_EVENTS.START, ...args);
|
|
148
|
+
expect(hookPlugin.state).toEqual(1);
|
|
149
|
+
});
|
|
147
150
|
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
it("calls invokes the handler on the hook manager", () => {
|
|
152
|
+
hookPlugin.setStateAndNotify(HOOKS_EVENTS.START, ...args);
|
|
150
153
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
expect(manager.subscriber.invokeHandler).toHaveBeenCalledWith(
|
|
155
|
+
HOOKS_EVENTS.START,
|
|
156
|
+
...args
|
|
157
|
+
);
|
|
158
|
+
});
|
|
155
159
|
});
|
|
156
|
-
});
|
|
157
160
|
|
|
158
|
-
describe("shouldPresentScreenHook", () => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
describe("shouldPresentScreenHook", () => {
|
|
162
|
+
it("returns true if the hook has a screenId and allows screen presentation", () => {
|
|
163
|
+
const hookPlugin = getHook({});
|
|
161
164
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
const hookWithoutRiver = getHook({
|
|
166
|
+
screen_id: undefined,
|
|
167
|
+
module: { presentFullScreen: true },
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
expect(hookPlugin.shouldPresentScreenHook()).toBe(true);
|
|
171
|
+
expect(hookWithoutRiver.shouldPresentScreenHook()).toBe(true);
|
|
165
172
|
});
|
|
166
173
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
it("returns true if the hook is modal presentation", () => {
|
|
175
|
+
const hookPlugin = getHook({
|
|
176
|
+
general: { transition_type: HOOKS_TRANSITION_TYPE.MODAL },
|
|
177
|
+
});
|
|
170
178
|
|
|
171
|
-
|
|
172
|
-
const hookPlugin = getHook({
|
|
173
|
-
general: { transition_type: HOOKS_TRANSITION_TYPE.MODAL },
|
|
179
|
+
expect(hookPlugin.shouldPresentScreenHook()).toBe(true);
|
|
174
180
|
});
|
|
175
181
|
|
|
176
|
-
|
|
177
|
-
|
|
182
|
+
it("returns false otherwise", () => {
|
|
183
|
+
const hookWithoutScreen = getHook({ screen_id: undefined });
|
|
178
184
|
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
const hookWithoutRiver = getHook({
|
|
186
|
+
screen_id: undefined,
|
|
187
|
+
module: { presentFullScreen: false },
|
|
188
|
+
});
|
|
181
189
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
});
|
|
190
|
+
const hookWithoutAllowScreen = getHook({
|
|
191
|
+
general: { allow_screen_plugin_presentation: false },
|
|
192
|
+
});
|
|
186
193
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
194
|
+
const hookWithoutScreenAndAllow = getHook({
|
|
195
|
+
general: { allow_screen_plugin_presentation: false },
|
|
196
|
+
screen_id: null,
|
|
197
|
+
});
|
|
190
198
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
199
|
+
expect(hookWithoutScreen.shouldPresentScreenHook()).toBeFalsy();
|
|
200
|
+
expect(hookWithoutAllowScreen.shouldPresentScreenHook()).toBeFalsy();
|
|
201
|
+
expect(hookWithoutScreenAndAllow.shouldPresentScreenHook()).toBeFalsy();
|
|
202
|
+
expect(hookWithoutRiver.shouldPresentScreenHook()).toBeFalsy();
|
|
194
203
|
});
|
|
195
|
-
|
|
196
|
-
expect(hookWithoutScreen.shouldPresentScreenHook()).toBeFalsy();
|
|
197
|
-
expect(hookWithoutAllowScreen.shouldPresentScreenHook()).toBeFalsy();
|
|
198
|
-
expect(hookWithoutScreenAndAllow.shouldPresentScreenHook()).toBeFalsy();
|
|
199
|
-
expect(hookWithoutRiver.shouldPresentScreenHook()).toBeFalsy();
|
|
200
204
|
});
|
|
201
|
-
});
|
|
202
205
|
|
|
203
|
-
describe("shouldStartNexHook", () => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
it("returns true if the nextHook has the same weight and is not a screen", () => {
|
|
208
|
-
expect(
|
|
209
|
-
hookWithoutScreen.shouldStartNextHook({
|
|
210
|
-
weight: hookWithoutScreen.weight,
|
|
211
|
-
})
|
|
212
|
-
).toBe(true);
|
|
213
|
-
});
|
|
206
|
+
describe("shouldStartNexHook", () => {
|
|
207
|
+
const hookPlugin = getHook({});
|
|
208
|
+
const hookWithoutScreen = getHook({ screen_id: undefined });
|
|
214
209
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
210
|
+
it("returns true if the nextHook has the same weight and is not a screen", () => {
|
|
211
|
+
expect(
|
|
212
|
+
hookWithoutScreen.shouldStartNextHook({
|
|
213
|
+
weight: hookWithoutScreen.weight,
|
|
214
|
+
})
|
|
215
|
+
).toBe(true);
|
|
216
|
+
});
|
|
219
217
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
218
|
+
it("returns false otherwise", () => {
|
|
219
|
+
// even if weight if the same, since hookPlugin should present a screen,
|
|
220
|
+
// it cannot run in parallel
|
|
221
|
+
expect(
|
|
222
|
+
hookPlugin.shouldStartNextHook({ weight: hookPlugin })
|
|
223
|
+
).toBeFalsy();
|
|
224
|
+
|
|
225
|
+
expect(
|
|
226
|
+
hookWithoutScreen.shouldStartNextHook({
|
|
227
|
+
weight: hookWithoutScreen.weight + 1,
|
|
228
|
+
})
|
|
229
|
+
).toBeFalsy();
|
|
230
|
+
});
|
|
225
231
|
});
|
|
226
|
-
});
|
|
227
232
|
|
|
228
|
-
describe("execute", () => {
|
|
229
|
-
|
|
230
|
-
|
|
233
|
+
describe("execute", () => {
|
|
234
|
+
const payload = { foo: "bar" };
|
|
235
|
+
const next = jest.fn();
|
|
231
236
|
|
|
232
|
-
|
|
237
|
+
beforeEach(clearMocks);
|
|
233
238
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
239
|
+
describe("when the hook execution should be skipped", () => {
|
|
240
|
+
it("doesn't execute the hook, and goes to the next", () => {
|
|
241
|
+
const hookPlugin = getHook({ module: { skipHook: () => true } });
|
|
242
|
+
hookPlugin.execute(payload, next);
|
|
238
243
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
244
|
+
expect(manager.presentScreenHook).not.toHaveBeenCalled();
|
|
245
|
+
expect(manager.executeHook).not.toHaveBeenCalled();
|
|
246
|
+
expect(next).toHaveBeenCalledWith({ payload, success: true });
|
|
247
|
+
});
|
|
242
248
|
});
|
|
243
|
-
});
|
|
244
249
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
+
describe("when the hook is not in pending state", () => {
|
|
251
|
+
it("doesn't execute the hook, and goes to the next", () => {
|
|
252
|
+
const hookPlugin = getHook({});
|
|
253
|
+
hookPlugin.setStateAndNotify(HOOKS_EVENTS.START);
|
|
254
|
+
hookPlugin.execute(payload, next);
|
|
250
255
|
|
|
251
|
-
|
|
256
|
+
const hookStateSpy = jest.spyOn(hookPlugin, "setStateAndNotify");
|
|
252
257
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
258
|
+
expect(hookStateSpy).not.toHaveBeenCalled();
|
|
259
|
+
expect(manager.presentScreenHook).not.toHaveBeenCalled();
|
|
260
|
+
expect(manager.executeHook).not.toHaveBeenCalled();
|
|
261
|
+
expect(next).toHaveBeenCalledWith({ payload });
|
|
257
262
|
|
|
258
|
-
|
|
263
|
+
hookStateSpy.mockRestore();
|
|
264
|
+
});
|
|
259
265
|
});
|
|
260
|
-
});
|
|
261
266
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
267
|
+
describe("when the screen should be presented", () => {
|
|
268
|
+
it("executes the hook", () => {
|
|
269
|
+
const hookPlugin = getHook({});
|
|
270
|
+
const hookStateSpy = jest.spyOn(hookPlugin, "setStateAndNotify");
|
|
266
271
|
|
|
267
|
-
|
|
272
|
+
hookPlugin.execute(payload, next);
|
|
268
273
|
|
|
269
|
-
|
|
274
|
+
expect(hookStateSpy).toHaveBeenCalledWith(
|
|
275
|
+
HOOKS_EVENTS.START,
|
|
276
|
+
hookPlugin
|
|
277
|
+
);
|
|
270
278
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
279
|
+
expect(manager.presentScreenHook).toHaveBeenCalledWith(
|
|
280
|
+
hookPlugin,
|
|
281
|
+
payload,
|
|
282
|
+
next
|
|
283
|
+
);
|
|
284
|
+
});
|
|
276
285
|
});
|
|
277
|
-
});
|
|
278
286
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
287
|
+
describe("when the hook is headless", () => {
|
|
288
|
+
it("executes the hook", () => {
|
|
289
|
+
const hookPlugin = getHook({
|
|
290
|
+
general: { allow_screen_plugin_presentation: false },
|
|
291
|
+
});
|
|
284
292
|
|
|
285
|
-
|
|
293
|
+
const hookStateSpy = jest.spyOn(hookPlugin, "setStateAndNotify");
|
|
286
294
|
|
|
287
|
-
|
|
295
|
+
hookPlugin.execute(payload, next);
|
|
288
296
|
|
|
289
|
-
|
|
297
|
+
expect(hookStateSpy).toHaveBeenCalledWith(
|
|
298
|
+
HOOKS_EVENTS.START,
|
|
299
|
+
hookPlugin
|
|
300
|
+
);
|
|
290
301
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
302
|
+
expect(manager.executeHook).toHaveBeenCalledWith(
|
|
303
|
+
hookPlugin,
|
|
304
|
+
payload,
|
|
305
|
+
next
|
|
306
|
+
);
|
|
307
|
+
});
|
|
296
308
|
});
|
|
297
309
|
});
|
|
298
310
|
});
|