@applicaster/zapp-react-native-utils 13.0.0-alpha.9433330286 → 13.0.0-rc.10

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 (37) hide show
  1. package/appUtils/HooksManager/{Hook.ts → Hook.js} +23 -35
  2. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +2 -4
  3. package/appUtils/HooksManager/__tests__/hook.test.js +184 -196
  4. package/appUtils/HooksManager/__tests__/hooksManager.test.js +99 -96
  5. package/appUtils/HooksManager/{constants.ts → constants.js} +1 -1
  6. package/appUtils/HooksManager/{index.ts → index.js} +112 -121
  7. package/appUtils/RiverFocusManager/index.js +12 -17
  8. package/appUtils/focusManager/treeDataStructure/Tree/index.js +3 -2
  9. package/appUtils/focusManager/treeDataStructure/Utils/index.js +3 -1
  10. package/appUtils/{index.ts → index.js} +1 -1
  11. package/appUtils/keyCodes/__tests__/keyCodes.test.js +3 -3
  12. package/appUtils/keyCodes/{index.ts → index.js} +0 -2
  13. package/appUtils/keyCodes/{keys/keyEventMapper.ts → keys.android.js} +19 -0
  14. package/appUtils/keyCodes/keys.ios.js +46 -0
  15. package/appUtils/platform/platformUtils.ts +14 -0
  16. package/appUtils/playerManager/index.ts +6 -2
  17. package/domUtils/{cookieManager.ts → cookieManager.js} +2 -1
  18. package/functionUtils/index.ts +11 -15
  19. package/modalState/index.ts +5 -1
  20. package/navigationUtils/index.ts +5 -14
  21. package/package.json +2 -2
  22. package/reactHooks/navigation/index.ts +4 -7
  23. package/reactUtils/index.ts +14 -0
  24. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -693
  25. package/appUtils/HooksManager/types.ts +0 -116
  26. package/appUtils/keyCodes/keys/index.ts +0 -3
  27. package/appUtils/keyCodes/keys/keys.android.ts +0 -18
  28. package/appUtils/keyCodes/keys/keys.ios.ts +0 -25
  29. package/appUtils/keyCodes/keys/keys.ts +0 -15
  30. package/appUtils/keyCodes/keysByPlatform.ts +0 -8
  31. /package/appUtils/HooksManager/{logger.ts → logger.js} +0 -0
  32. /package/appUtils/{directionHelper.ts → directionHelper.js} +0 -0
  33. /package/appUtils/keyCodes/{androidTVKeys.ts → androidTVKeys.js} +0 -0
  34. /package/appUtils/keyCodes/{keys/keys.web.ts → keys.web.js} +0 -0
  35. /package/appUtils/keyCodes/{keys/keysByPlatform.ts → keysByPlatform.js} +0 -0
  36. /package/appUtils/{localizationsHelper.ts → localizationsHelper.js} +0 -0
  37. /package/domUtils/{logger.ts → logger.js} +0 -0
@@ -4,7 +4,6 @@ import { isFunction } from "../../functionUtils";
4
4
  import { HOOKS_EVENTS, HOOKS_TRANSITION_TYPE } from "./constants";
5
5
 
6
6
  import { hooksManagerLogger } from "./logger";
7
- import type { Hook as HookInterface, HookIniObj } from "./types";
8
7
 
9
8
  const BASE_HOOK_PROPERTIES = ["screen_id", "identifier", "weight"];
10
9
 
@@ -15,9 +14,7 @@ const BASE_HOOK_PROPERTIES = ["screen_id", "identifier", "weight"];
15
14
  * @param {string} hookEventName
16
15
  * @returns {number} index
17
16
  */
18
- const hookState: (
19
- arg0: typeof HOOKS_EVENTS[keyof typeof HOOKS_EVENTS]
20
- ) => number = R.indexOf(R.__, R.values(HOOKS_EVENTS));
17
+ const hookState = R.indexOf(R.__, R.values(HOOKS_EVENTS));
21
18
 
22
19
  /**
23
20
  * assigns property to a given context
@@ -31,20 +28,17 @@ function assignProp(context) {
31
28
  }
32
29
 
33
30
  /**
34
- * Representation of a hook plugin
31
+ * Representation of a hook plugin with full data
35
32
  */
36
- export class Hook implements HookInterface {
37
- public manager: HookInterface["manager"];
38
- public lastHook: HookInterface["lastHook"];
39
- public state: HookInterface["state"];
40
- public screen_id: HookInterface["screen_id"];
41
- public identifier: HookInterface["identifier"];
42
- public module: HookInterface["module"];
43
- public general: HookInterface["general"];
44
- public weight: number;
45
- public configuration: HookInterface["configuration"];
46
-
47
- constructor({ hook, hooks, manager }: HookIniObj) {
33
+ export class Hook {
34
+ /**
35
+ * constructs the hook
36
+ * @param {object} Options
37
+ * @param {object} Options.hook hook object
38
+ * @param {Array<Object>} Options.hooks array of hooks siblings in the current process
39
+ * @param {object} manager hook manager to process the hooks
40
+ */
41
+ constructor({ hook, hooks, manager }) {
48
42
  R.forEachObjIndexed(assignProp(this), hook);
49
43
  this.manager = manager;
50
44
 
@@ -61,28 +55,25 @@ export class Hook implements HookInterface {
61
55
  * @param {string} event name
62
56
  * @param {Array<Any>} args variadic arguments to invoke the handler with
63
57
  */
64
- setStateAndNotify(
65
- event: typeof HOOKS_EVENTS[keyof typeof HOOKS_EVENTS],
66
- ...args
67
- ) {
58
+ setStateAndNotify(event, ...args) {
68
59
  this.state = hookState(event);
69
- this.manager.subscriber.invokeHandler(event, ...args);
60
+ this.manager.invokeHandler(event, ...args);
70
61
  }
71
62
 
72
63
  /**
73
64
  * returns react component of the the hook modal presenter
74
65
  * @returns {React.ComponentType<any>}
75
66
  */
76
- getModalContainer(): HookInterface["module"]["ModalContainer"] | undefined {
77
- return this.module ? this.module.ModalContainer : undefined;
67
+ getModalContainer() {
68
+ return this.module && this.module.ModalContainer;
78
69
  }
79
70
 
80
71
  /**
81
72
  * tells whether the hook should be presented as a screen
82
73
  * @returns {boolean}
83
74
  */
84
- shouldPresentScreenHook(): boolean {
85
- return !!(
75
+ shouldPresentScreenHook() {
76
+ return (
86
77
  (this.screen_id && this.general?.allow_screen_plugin_presentation) ||
87
78
  (this.module && this.module.presentFullScreen) ||
88
79
  (!this.module?.presentFullScreen &&
@@ -96,7 +87,7 @@ export class Hook implements HookInterface {
96
87
  * tells whether the hook should be presented as a modal screen
97
88
  * @returns {boolean}
98
89
  */
99
- isModalHook(): boolean {
90
+ isModalHook() {
100
91
  return (
101
92
  this.screen_id &&
102
93
  this.general?.transition_type === HOOKS_TRANSITION_TYPE.MODAL
@@ -108,7 +99,7 @@ export class Hook implements HookInterface {
108
99
  * if it doesn't return success
109
100
  * @returns { boolean}
110
101
  */
111
- isFlowBlocker(): boolean {
102
+ isFlowBlocker() {
112
103
  return (
113
104
  (this.general && this.general.is_flow_blocker) ||
114
105
  (this.module && this.module.isFlowBlocker && this.module.isFlowBlocker())
@@ -120,7 +111,7 @@ export class Hook implements HookInterface {
120
111
  * @param {object} payload to pass to the hook
121
112
  * @returns { boolean}
122
113
  */
123
- skipHook(payload: object): boolean {
114
+ skipHook(payload) {
124
115
  const _skipHook = R.compose(
125
116
  R.ifElse(isFunction, R.apply(R.__, [payload]), R.F),
126
117
  R.path(["module", "skipHook"])
@@ -142,10 +133,7 @@ export class Hook implements HookInterface {
142
133
  * @param {object} payload to pass to the hook
143
134
  * @param {function} next callback to invoke for processing next hook
144
135
  */
145
- execute<T extends object>(
146
- payload: T,
147
- next: (arg0: { payload: T; success?: boolean }) => void
148
- ): void {
136
+ execute(payload, next) {
149
137
  if (this.skipHook(payload)) {
150
138
  next({ payload, success: true });
151
139
 
@@ -164,7 +152,7 @@ export class Hook implements HookInterface {
164
152
 
165
153
  this.setStateAndNotify(HOOKS_EVENTS.START_BACKGROUND_HOOK, this);
166
154
 
167
- this.manager.runInBackground(this, payload, next, (_payload: any) =>
155
+ this.manager.runInBackground(this, payload, next, (_payload) =>
168
156
  this.manager.presentScreenHook(this, _payload || payload, next)
169
157
  );
170
158
  } else if (this.shouldPresentScreenHook()) {
@@ -187,7 +175,7 @@ export class Hook implements HookInterface {
187
175
  * - AND next hook has the same weight as the current one
188
176
  * @returns {boolean}
189
177
  */
190
- shouldStartNextHook(nextHook: Hook): boolean {
178
+ shouldStartNextHook(nextHook) {
191
179
  return (
192
180
  nextHook &&
193
181
  !this.shouldPresentScreenHook() &&
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Hook Hook Properties has all the hook properties 1`] = `
3
+ exports[`Hook Properties has all the hook properties 1`] = `
4
4
  Hook {
5
5
  "advertising": Object {},
6
6
  "general": Object {
@@ -13,10 +13,8 @@ Hook {
13
13
  "lastHook": true,
14
14
  "manager": Object {
15
15
  "executeHook": [MockFunction],
16
+ "invokeHandler": [MockFunction],
16
17
  "presentScreenHook": [MockFunction],
17
- "subscriber": Object {
18
- "invokeHandler": [MockFunction],
19
- },
20
18
  },
21
19
  "name": "Hook Screen",
22
20
  "navigations": Array [],
@@ -29,9 +29,7 @@ const hooks = (options, otherHook = null) =>
29
29
  const manager = {
30
30
  presentScreenHook: jest.fn(),
31
31
  executeHook: jest.fn(),
32
- subscriber: {
33
- invokeHandler: jest.fn(),
34
- },
32
+ invokeHandler: jest.fn(),
35
33
  };
36
34
 
37
35
  const getHook = (options, otherHook) =>
@@ -44,267 +42,257 @@ const getHook = (options, otherHook) =>
44
42
  function clearMocks() {
45
43
  manager.presentScreenHook.mockClear();
46
44
  manager.executeHook.mockClear();
47
- manager.subscriber.invokeHandler.mockClear();
45
+ manager.invokeHandler.mockClear();
48
46
  }
49
47
 
50
- describe("Hook", () => {
51
- describe("Hook Properties", () => {
52
- const hookPlugin = getHook({});
48
+ describe("Hook Properties", () => {
49
+ const hookPlugin = getHook({});
53
50
 
54
- beforeEach(clearMocks);
51
+ beforeEach(clearMocks);
55
52
 
56
- it("has all the hook properties", () => {
57
- expect(hookPlugin).toMatchSnapshot();
58
- });
53
+ it("has all the hook properties", () => {
54
+ expect(hookPlugin).toMatchSnapshot();
59
55
  });
56
+ });
60
57
 
61
- describe("getModalContainer", () => {
62
- it("returns ModalContainer", () => {
63
- const ModalContainer = jest.fn();
64
-
65
- const hookPlugin = getHook({
66
- general: {},
67
- module: { ModalContainer },
68
- });
58
+ describe("getModalContainer", () => {
59
+ it("returns ModalContainer", () => {
60
+ const ModalContainer = jest.fn();
69
61
 
70
- expect(hookPlugin.getModalContainer()).toBe(ModalContainer);
62
+ const hookPlugin = getHook({
63
+ general: {},
64
+ module: { ModalContainer },
71
65
  });
66
+
67
+ expect(hookPlugin.getModalContainer()).toBe(ModalContainer);
72
68
  });
69
+ });
73
70
 
74
- describe("isFlowBlocker", () => {
75
- it("returns true if the hook is flow blocker", () => {
76
- const hookPlugin = getHook({ general: { is_flow_blocker: true } });
71
+ describe("isFlowBlocker", () => {
72
+ it("returns true if the hook is flow blocker", () => {
73
+ const hookPlugin = getHook({ general: { is_flow_blocker: true } });
77
74
 
78
- const hookWithoutScreen = getHook({
79
- general: {},
80
- module: { isFlowBlocker: () => true },
81
- });
82
-
83
- expect(hookPlugin.isFlowBlocker()).toBe(true);
84
- expect(hookWithoutScreen.isFlowBlocker()).toBe(true);
75
+ const hookWithoutScreen = getHook({
76
+ general: {},
77
+ module: { isFlowBlocker: () => true },
85
78
  });
86
79
 
87
- it("returns false otherwise", () => {
88
- const hookPlugin = getHook({ general: { is_flow_blocker: false } });
80
+ expect(hookPlugin.isFlowBlocker()).toBe(true);
81
+ expect(hookWithoutScreen.isFlowBlocker()).toBe(true);
82
+ });
89
83
 
90
- const hookWithoutScreen = getHook({
91
- general: {},
92
- module: { isFlowBlocker: () => false },
93
- });
84
+ it("returns false otherwise", () => {
85
+ const hookPlugin = getHook({ general: { is_flow_blocker: false } });
94
86
 
95
- expect(hookPlugin.isFlowBlocker()).toBeFalsy();
96
- expect(hookWithoutScreen.isFlowBlocker()).toBeFalsy();
87
+ const hookWithoutScreen = getHook({
88
+ general: {},
89
+ module: { isFlowBlocker: () => false },
97
90
  });
91
+
92
+ expect(hookPlugin.isFlowBlocker()).toBeFalsy();
93
+ expect(hookWithoutScreen.isFlowBlocker()).toBeFalsy();
98
94
  });
95
+ });
99
96
 
100
- describe("skipHook", () => {
101
- it("returns true if the hooks module skipHook method returns true", () => {
102
- const hookPlugin = getHook({ module: { skipHook: () => true } });
97
+ describe("skipHook", () => {
98
+ it("returns true if the hooks module skipHook method returns true", () => {
99
+ const hookPlugin = getHook({ module: { skipHook: () => true } });
103
100
 
104
- expect(hookPlugin.skipHook()).toBe(true);
105
- });
101
+ expect(hookPlugin.skipHook()).toBe(true);
102
+ });
106
103
 
107
- it("returns false otherwise", () => {
108
- const hookPlugin = getHook({ module: { skipHook: false } });
109
- const hookPluginWithUndefinedSkipHook = getHook({ module: {} });
104
+ it("returns false otherwise", () => {
105
+ const hookPlugin = getHook({ module: { skipHook: false } });
106
+ const hookPluginWithUndefinedSkipHook = getHook({ module: {} });
110
107
 
111
- expect(hookPlugin.skipHook()).toBeFalsy();
112
- expect(hookPluginWithUndefinedSkipHook.skipHook()).toBeFalsy();
113
- });
108
+ expect(hookPlugin.skipHook()).toBeFalsy();
109
+ expect(hookPluginWithUndefinedSkipHook.skipHook()).toBeFalsy();
114
110
  });
111
+ });
115
112
 
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
- });
121
-
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
- );
113
+ describe("lastHook", () => {
114
+ it("returns true if the current hook is the last one", () => {
115
+ const hookPlugin = getHook({});
116
+ expect(hookPlugin.lastHook).toBe(true);
117
+ });
132
118
 
133
- expect(hookPlugin.lastHook).toBe(false);
134
- });
119
+ it("returns false otherwise", () => {
120
+ const hookPlugin = getHook(
121
+ {},
122
+ {
123
+ screen_id: "B4567",
124
+ type: "general",
125
+ identifier: "some_hook",
126
+ weight: 2,
127
+ }
128
+ );
129
+
130
+ expect(hookPlugin.lastHook).toBe(false);
135
131
  });
132
+ });
136
133
 
137
- describe("setStateAndNotify", () => {
138
- let hookPlugin;
139
- const args = ["foo", { bar: 42 }];
134
+ describe("setStateAndNotify", () => {
135
+ let hookPlugin;
136
+ const args = ["foo", { bar: 42 }];
140
137
 
141
- beforeEach(() => {
142
- clearMocks();
143
- hookPlugin = getHook({});
144
- });
138
+ beforeEach(() => {
139
+ clearMocks();
140
+ hookPlugin = getHook({});
141
+ });
145
142
 
146
- it("changes the hook's state", () => {
147
- hookPlugin.setStateAndNotify(HOOKS_EVENTS.START, ...args);
148
- expect(hookPlugin.state).toEqual(1);
149
- });
143
+ it("changes the hook's state", () => {
144
+ hookPlugin.setStateAndNotify(HOOKS_EVENTS.START, ...args);
145
+ expect(hookPlugin.state).toEqual(1);
146
+ });
150
147
 
151
- it("calls invokes the handler on the hook manager", () => {
152
- hookPlugin.setStateAndNotify(HOOKS_EVENTS.START, ...args);
148
+ it("calls invokes the handler on the hook manager", () => {
149
+ hookPlugin.setStateAndNotify(HOOKS_EVENTS.START, ...args);
153
150
 
154
- expect(manager.subscriber.invokeHandler).toHaveBeenCalledWith(
155
- HOOKS_EVENTS.START,
156
- ...args
157
- );
158
- });
151
+ expect(manager.invokeHandler).toHaveBeenCalledWith(
152
+ HOOKS_EVENTS.START,
153
+ ...args
154
+ );
159
155
  });
156
+ });
160
157
 
161
- describe("shouldPresentScreenHook", () => {
162
- it("returns true if the hook has a screenId and allows screen presentation", () => {
163
- const hookPlugin = getHook({});
164
-
165
- const hookWithoutRiver = getHook({
166
- screen_id: undefined,
167
- module: { presentFullScreen: true },
168
- });
158
+ describe("shouldPresentScreenHook", () => {
159
+ it("returns true if the hook has a screenId and allows screen presentation", () => {
160
+ const hookPlugin = getHook({});
169
161
 
170
- expect(hookPlugin.shouldPresentScreenHook()).toBe(true);
171
- expect(hookWithoutRiver.shouldPresentScreenHook()).toBe(true);
162
+ const hookWithoutRiver = getHook({
163
+ screen_id: undefined,
164
+ module: { presentFullScreen: true },
172
165
  });
173
166
 
174
- it("returns true if the hook is modal presentation", () => {
175
- const hookPlugin = getHook({
176
- general: { transition_type: HOOKS_TRANSITION_TYPE.MODAL },
177
- });
167
+ expect(hookPlugin.shouldPresentScreenHook()).toBe(true);
168
+ expect(hookWithoutRiver.shouldPresentScreenHook()).toBe(true);
169
+ });
178
170
 
179
- expect(hookPlugin.shouldPresentScreenHook()).toBe(true);
171
+ it("returns true if the hook is modal presentation", () => {
172
+ const hookPlugin = getHook({
173
+ general: { transition_type: HOOKS_TRANSITION_TYPE.MODAL },
180
174
  });
181
175
 
182
- it("returns false otherwise", () => {
183
- const hookWithoutScreen = getHook({ screen_id: undefined });
176
+ expect(hookPlugin.shouldPresentScreenHook()).toBe(true);
177
+ });
184
178
 
185
- const hookWithoutRiver = getHook({
186
- screen_id: undefined,
187
- module: { presentFullScreen: false },
188
- });
179
+ it("returns false otherwise", () => {
180
+ const hookWithoutScreen = getHook({ screen_id: undefined });
189
181
 
190
- const hookWithoutAllowScreen = getHook({
191
- general: { allow_screen_plugin_presentation: false },
192
- });
182
+ const hookWithoutRiver = getHook({
183
+ screen_id: undefined,
184
+ module: { presentFullScreen: false },
185
+ });
193
186
 
194
- const hookWithoutScreenAndAllow = getHook({
195
- general: { allow_screen_plugin_presentation: false },
196
- screen_id: null,
197
- });
187
+ const hookWithoutAllowScreen = getHook({
188
+ general: { allow_screen_plugin_presentation: false },
189
+ });
198
190
 
199
- expect(hookWithoutScreen.shouldPresentScreenHook()).toBeFalsy();
200
- expect(hookWithoutAllowScreen.shouldPresentScreenHook()).toBeFalsy();
201
- expect(hookWithoutScreenAndAllow.shouldPresentScreenHook()).toBeFalsy();
202
- expect(hookWithoutRiver.shouldPresentScreenHook()).toBeFalsy();
191
+ const hookWithoutScreenAndAllow = getHook({
192
+ general: { allow_screen_plugin_presentation: false },
193
+ screen_id: null,
203
194
  });
195
+
196
+ expect(hookWithoutScreen.shouldPresentScreenHook()).toBeFalsy();
197
+ expect(hookWithoutAllowScreen.shouldPresentScreenHook()).toBeFalsy();
198
+ expect(hookWithoutScreenAndAllow.shouldPresentScreenHook()).toBeFalsy();
199
+ expect(hookWithoutRiver.shouldPresentScreenHook()).toBeFalsy();
204
200
  });
201
+ });
205
202
 
206
- describe("shouldStartNexHook", () => {
207
- const hookPlugin = getHook({});
208
- const hookWithoutScreen = getHook({ screen_id: undefined });
203
+ describe("shouldStartNexHook", () => {
204
+ const hookPlugin = getHook({});
205
+ const hookWithoutScreen = getHook({ screen_id: undefined });
209
206
 
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
- });
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
+ });
217
214
 
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
- });
215
+ it("returns false otherwise", () => {
216
+ // even if weight if the same, since hookPlugin should present a screen,
217
+ // it cannot run in parallel
218
+ expect(hookPlugin.shouldStartNextHook({ weight: hookPlugin })).toBeFalsy();
219
+
220
+ expect(
221
+ hookWithoutScreen.shouldStartNextHook({
222
+ weight: hookWithoutScreen.weight + 1,
223
+ })
224
+ ).toBeFalsy();
231
225
  });
226
+ });
232
227
 
233
- describe("execute", () => {
234
- const payload = { foo: "bar" };
235
- const next = jest.fn();
228
+ describe("execute", () => {
229
+ const payload = { foo: "bar" };
230
+ const next = jest.fn();
236
231
 
237
- beforeEach(clearMocks);
232
+ beforeEach(clearMocks);
238
233
 
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);
234
+ describe("when the hook execution should be skipped", () => {
235
+ it("doesn't execute the hook, and goes to the next", () => {
236
+ const hookPlugin = getHook({ module: { skipHook: () => true } });
237
+ hookPlugin.execute(payload, next);
243
238
 
244
- expect(manager.presentScreenHook).not.toHaveBeenCalled();
245
- expect(manager.executeHook).not.toHaveBeenCalled();
246
- expect(next).toHaveBeenCalledWith({ payload, success: true });
247
- });
239
+ expect(manager.presentScreenHook).not.toHaveBeenCalled();
240
+ expect(manager.executeHook).not.toHaveBeenCalled();
241
+ expect(next).toHaveBeenCalledWith({ payload, success: true });
248
242
  });
243
+ });
249
244
 
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);
245
+ describe("when the hook is not in pending state", () => {
246
+ it("doesn't execute the hook, and goes to the next", () => {
247
+ const hookPlugin = getHook({});
248
+ hookPlugin.setStateAndNotify(HOOKS_EVENTS.START);
249
+ hookPlugin.execute(payload, next);
255
250
 
256
- const hookStateSpy = jest.spyOn(hookPlugin, "setStateAndNotify");
251
+ const hookStateSpy = jest.spyOn(hookPlugin, "setStateAndNotify");
257
252
 
258
- expect(hookStateSpy).not.toHaveBeenCalled();
259
- expect(manager.presentScreenHook).not.toHaveBeenCalled();
260
- expect(manager.executeHook).not.toHaveBeenCalled();
261
- expect(next).toHaveBeenCalledWith({ payload });
253
+ expect(hookStateSpy).not.toHaveBeenCalled();
254
+ expect(manager.presentScreenHook).not.toHaveBeenCalled();
255
+ expect(manager.executeHook).not.toHaveBeenCalled();
256
+ expect(next).toHaveBeenCalledWith({ payload });
262
257
 
263
- hookStateSpy.mockRestore();
264
- });
258
+ hookStateSpy.mockRestore();
265
259
  });
260
+ });
266
261
 
267
- describe("when the screen should be presented", () => {
268
- it("executes the hook", () => {
269
- const hookPlugin = getHook({});
270
- const hookStateSpy = jest.spyOn(hookPlugin, "setStateAndNotify");
262
+ describe("when the screen should be presented", () => {
263
+ it("executes the hook", () => {
264
+ const hookPlugin = getHook({});
265
+ const hookStateSpy = jest.spyOn(hookPlugin, "setStateAndNotify");
271
266
 
272
- hookPlugin.execute(payload, next);
267
+ hookPlugin.execute(payload, next);
273
268
 
274
- expect(hookStateSpy).toHaveBeenCalledWith(
275
- HOOKS_EVENTS.START,
276
- hookPlugin
277
- );
269
+ expect(hookStateSpy).toHaveBeenCalledWith(HOOKS_EVENTS.START, hookPlugin);
278
270
 
279
- expect(manager.presentScreenHook).toHaveBeenCalledWith(
280
- hookPlugin,
281
- payload,
282
- next
283
- );
284
- });
271
+ expect(manager.presentScreenHook).toHaveBeenCalledWith(
272
+ hookPlugin,
273
+ payload,
274
+ next
275
+ );
285
276
  });
277
+ });
286
278
 
287
- describe("when the hook is headless", () => {
288
- it("executes the hook", () => {
289
- const hookPlugin = getHook({
290
- general: { allow_screen_plugin_presentation: false },
291
- });
279
+ describe("when the hook is headless", () => {
280
+ it("executes the hook", () => {
281
+ const hookPlugin = getHook({
282
+ general: { allow_screen_plugin_presentation: false },
283
+ });
292
284
 
293
- const hookStateSpy = jest.spyOn(hookPlugin, "setStateAndNotify");
285
+ const hookStateSpy = jest.spyOn(hookPlugin, "setStateAndNotify");
294
286
 
295
- hookPlugin.execute(payload, next);
287
+ hookPlugin.execute(payload, next);
296
288
 
297
- expect(hookStateSpy).toHaveBeenCalledWith(
298
- HOOKS_EVENTS.START,
299
- hookPlugin
300
- );
289
+ expect(hookStateSpy).toHaveBeenCalledWith(HOOKS_EVENTS.START, hookPlugin);
301
290
 
302
- expect(manager.executeHook).toHaveBeenCalledWith(
303
- hookPlugin,
304
- payload,
305
- next
306
- );
307
- });
291
+ expect(manager.executeHook).toHaveBeenCalledWith(
292
+ hookPlugin,
293
+ payload,
294
+ next
295
+ );
308
296
  });
309
297
  });
310
298
  });