@applicaster/zapp-react-native-utils 16.0.0-alpha.4380012274 → 16.0.0-alpha.4548770949
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/__tests__/StorageActions.test.ts +98 -0
- package/actionsExecutor/__tests__/feedDecorator.test.ts +30 -0
- package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +72 -0
- package/actionsExecutor/actions/openBottomSheet.ts +1 -0
- package/actionsExecutor/actions/screenToggleFlag.ts +1 -3
- package/actionsExecutor/feedDecorator.ts +6 -0
- package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -22
- package/appUtils/contextKeysManager/__tests__/getKey/success/fullSearch.test.ts +1 -25
- package/appUtils/contextKeysManager/__tests__/getKey/success/searchInSecure.test.ts +1 -7
- package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +0 -25
- package/appUtils/contextKeysManager/__tests__/removeKey/success.test.ts +0 -6
- package/appUtils/contextKeysManager/__tests__/setKey/failure/failedToSaveInStorage.test.ts +0 -40
- package/appUtils/contextKeysManager/__tests__/setKey/{success/saveItemAndReference.test.ts → success.test.ts} +2 -42
- package/appUtils/contextKeysManager/index.ts +28 -129
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +11 -0
- package/modalState/ModalOrchestrator.ts +1 -0
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +23 -0
- package/modalState/index.ts +2 -0
- package/modalState/types.ts +11 -0
- package/package.json +2 -2
- package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
- package/reactHooks/feed/useFeedLoader.tsx +28 -1
- package/reactHooks/feed/useLoadPipesDataDispatch.ts +12 -11
- package/appUtils/contextKeysManager/__tests__/getKey/success/byReference.test.ts +0 -56
- package/appUtils/contextKeysManager/__tests__/getKeyByReference/failure.test.ts +0 -265
- package/appUtils/contextKeysManager/__tests__/getKeyByReference/success.test.ts +0 -303
- package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/failure.test.ts +0 -82
- package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/success.test.ts +0 -41
- package/appUtils/contextKeysManager/__tests__/setKey/success/saveItemButNotReference.test.ts +0 -208
- package/appUtils/contextKeysManager/__tests__/setReferenceForKey/failure.test.ts +0 -93
- package/appUtils/contextKeysManager/__tests__/setReferenceForKey/success.test.ts +0 -45
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ActionResult } from "../ActionExecutor";
|
|
2
|
+
import { localStorageToggleFlag } from "../StorageActions";
|
|
3
|
+
import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "../consts";
|
|
4
|
+
import { postEvent } from "../../reactHooks/useSubscriberFor";
|
|
5
|
+
|
|
6
|
+
jest.mock("../ActionExecutorContext", () => ({
|
|
7
|
+
log_error: jest.fn(),
|
|
8
|
+
log_info: jest.fn(),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
jest.mock("../../reactHooks/useSubscriberFor", () => ({
|
|
12
|
+
postEvent: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
// In-memory stand-in for the storage-backed provider; the limit check under
|
|
16
|
+
// test lives in storageToggleFlag, not in the provider.
|
|
17
|
+
const mockStore: Record<string, string[]> = {};
|
|
18
|
+
|
|
19
|
+
jest.mock("../../storage/StorageMultiSelectProvider", () => ({
|
|
20
|
+
StorageMultiSelectProvider: {
|
|
21
|
+
getProvider: (keyNamespace: string) => ({
|
|
22
|
+
getSelectedAsync: async () => [...(mockStore[keyNamespace] ?? [])],
|
|
23
|
+
addItem: async (item: string) => {
|
|
24
|
+
mockStore[keyNamespace] = [...(mockStore[keyNamespace] ?? []), item];
|
|
25
|
+
},
|
|
26
|
+
removeItem: async (item: string) => {
|
|
27
|
+
mockStore[keyNamespace] = (mockStore[keyNamespace] ?? []).filter(
|
|
28
|
+
(it) => it !== item
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
const KEY = "user_preferences.teams";
|
|
36
|
+
|
|
37
|
+
// Entries of a team selection feed with explicit tap actions
|
|
38
|
+
// (localStorageToggleFlag with key and selector).
|
|
39
|
+
const teamEntry = (n: number) =>
|
|
40
|
+
({
|
|
41
|
+
id: `team-${n}`,
|
|
42
|
+
title: `Team ${n}`,
|
|
43
|
+
type: { value: "action" },
|
|
44
|
+
extensions: { tag: `TEAM ${n}` },
|
|
45
|
+
}) as unknown as ZappEntry;
|
|
46
|
+
|
|
47
|
+
const tapAction = (extraOptions = {}) =>
|
|
48
|
+
({
|
|
49
|
+
type: "localStorageToggleFlag",
|
|
50
|
+
options: { key: KEY, selector: "extensions.tag", ...extraOptions },
|
|
51
|
+
}) as unknown as ActionType;
|
|
52
|
+
|
|
53
|
+
const tapTeams = async (count: number, extraOptions = {}) => {
|
|
54
|
+
const results: ActionResult[] = [];
|
|
55
|
+
|
|
56
|
+
for (let n = 1; n <= count; n++) {
|
|
57
|
+
results.push(
|
|
58
|
+
await localStorageToggleFlag(
|
|
59
|
+
{ entry: teamEntry(n) },
|
|
60
|
+
tapAction(extraOptions)
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return results;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
describe("localStorageToggleFlag max_items", () => {
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
delete mockStore[KEY];
|
|
71
|
+
jest.clearAllMocks();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("blocks the 11th team when max_items is in the action options", async () => {
|
|
75
|
+
const results = await tapTeams(11, { max_items: "10" });
|
|
76
|
+
|
|
77
|
+
expect(results.slice(0, 10)).toEqual(Array(10).fill(ActionResult.Success));
|
|
78
|
+
expect(results[10]).toBe(ActionResult.Cancel);
|
|
79
|
+
expect(mockStore[KEY]).toHaveLength(10);
|
|
80
|
+
|
|
81
|
+
expect(postEvent).toHaveBeenCalledWith(
|
|
82
|
+
TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT,
|
|
83
|
+
[expect.objectContaining({ maxItems: "10", tag: "TEAM 11" })]
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("still lets a selected team be removed at the limit", async () => {
|
|
88
|
+
await tapTeams(10, { max_items: "10" });
|
|
89
|
+
|
|
90
|
+
const result = await localStorageToggleFlag(
|
|
91
|
+
{ entry: teamEntry(1) },
|
|
92
|
+
tapAction({ max_items: "10" })
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
expect(result).toBe(ActionResult.Success);
|
|
96
|
+
expect(mockStore[KEY]).toHaveLength(9);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -59,3 +59,33 @@ describe("decorateFeed", () => {
|
|
|
59
59
|
expect(decorated.entry[0].extensions.tap_actions).toBeUndefined();
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
+
|
|
63
|
+
describe("decorateFeed max_items", () => {
|
|
64
|
+
const toggleAction = (feed: ZappFeed) =>
|
|
65
|
+
decorateFeed(feed).entry[0].extensions.tap_actions.actions[0];
|
|
66
|
+
|
|
67
|
+
it.each([
|
|
68
|
+
["screen", "screenToggleFlag"],
|
|
69
|
+
["session", "sessionStorageToggleFlag"],
|
|
70
|
+
["ctx", "localStorageToggleFlag"],
|
|
71
|
+
])("passes max_items to the %s toggle action", (scope, type) => {
|
|
72
|
+
const feed = preferenceFeed("multi");
|
|
73
|
+
feed.extensions.preference_editor_options.scope = scope;
|
|
74
|
+
feed.extensions.preference_editor_options.max_items = "10";
|
|
75
|
+
|
|
76
|
+
const toggle = toggleAction(feed);
|
|
77
|
+
|
|
78
|
+
expect(toggle.type).toBe(type);
|
|
79
|
+
expect(toggle.options).toEqual({ key: "agree", max_items: 10 });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it.each([undefined, 0, "0", "ten", -1])(
|
|
83
|
+
"does not set a limit for max_items %p",
|
|
84
|
+
(maxItems) => {
|
|
85
|
+
const feed = preferenceFeed("multi");
|
|
86
|
+
feed.extensions.preference_editor_options.max_items = maxItems;
|
|
87
|
+
|
|
88
|
+
expect(toggleAction(feed).options).toEqual({ key: "agree" });
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ActionExecutor, ActionResult } from "../ActionExecutor";
|
|
2
|
+
import { screenToggleFlagAction } from "../actions/screenToggleFlag";
|
|
3
|
+
|
|
4
|
+
jest.mock("../ActionExecutorContext", () => ({
|
|
5
|
+
log_error: jest.fn(),
|
|
6
|
+
log_info: jest.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
jest.mock("../StorageActions", () => ({
|
|
10
|
+
onMaxTagsReached: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
// not used here, but it pulls the native bridge logger in at import time
|
|
14
|
+
jest.mock("../../storage/ScreenSingleValueProvider", () => ({}));
|
|
15
|
+
|
|
16
|
+
jest.mock("../../logger", () => ({
|
|
17
|
+
createLogger: () => ({
|
|
18
|
+
log_error: jest.fn(),
|
|
19
|
+
log_debug: jest.fn(),
|
|
20
|
+
log_info: jest.fn(),
|
|
21
|
+
}),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const mockSelected: string[] = [];
|
|
25
|
+
|
|
26
|
+
jest.mock("../../storage/ScreenStateMultiSelectProvider", () => ({
|
|
27
|
+
ScreenMultiSelectProvider: {
|
|
28
|
+
getProvider: () => ({
|
|
29
|
+
getSelectedAsync: async () => [...mockSelected],
|
|
30
|
+
addItem: async (item: string) => {
|
|
31
|
+
mockSelected.push(item);
|
|
32
|
+
},
|
|
33
|
+
removeItem: async (item: string) => {
|
|
34
|
+
mockSelected.splice(mockSelected.indexOf(item), 1);
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
const toggleAction = (options = {}) =>
|
|
41
|
+
({
|
|
42
|
+
type: "screenToggleFlag",
|
|
43
|
+
options: { key: "teams", selector: "extensions.tag", ...options },
|
|
44
|
+
}) as unknown as ActionType;
|
|
45
|
+
|
|
46
|
+
const context = (tag: string) => ({
|
|
47
|
+
screenRoute: "/screen",
|
|
48
|
+
screenStateStore: {},
|
|
49
|
+
entry: { id: tag, extensions: { tag } },
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe("screenToggleFlagAction at the max_items limit", () => {
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
mockSelected.length = 0;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("returns the cancellation so the chained actions do not run", async () => {
|
|
58
|
+
const afterToggle = jest.fn();
|
|
59
|
+
const executor = new ActionExecutor();
|
|
60
|
+
|
|
61
|
+
executor.registerAction("screenToggleFlag", screenToggleFlagAction);
|
|
62
|
+
|
|
63
|
+
executor.registerAction("sendCloudEvent", async () => {
|
|
64
|
+
afterToggle();
|
|
65
|
+
|
|
66
|
+
return ActionResult.Success;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
mockSelected.push("A", "B");
|
|
70
|
+
|
|
71
|
+
const result = await executor.handleActions(
|
|
72
|
+
[toggleAction({ max_items: 2 }), { type: "sendCloudEvent" }],
|
|
73
|
+
context("C") as never
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
expect(result).toBe(ActionResult.Cancel);
|
|
77
|
+
expect(afterToggle).not.toHaveBeenCalled();
|
|
78
|
+
expect(mockSelected).toEqual(["A", "B"]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("lets the chain continue below the limit", async () => {
|
|
82
|
+
const result = await screenToggleFlagAction(
|
|
83
|
+
toggleAction({ max_items: 2 }),
|
|
84
|
+
context("A") as never
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(result).toBe(ActionResult.Success);
|
|
88
|
+
expect(mockSelected).toEqual(["A"]);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -2,6 +2,22 @@ import { openBottomSheetAction } from "../openBottomSheet";
|
|
|
2
2
|
import { actionExecutor, ActionResult } from "../../ActionExecutor";
|
|
3
3
|
import { modalOrchestrator } from "../../../modalState/ModalOrchestrator";
|
|
4
4
|
|
|
5
|
+
jest.mock("@applicaster/zapp-pipes-v2-client", () => ({
|
|
6
|
+
PipesClientResponseHelper: jest.fn(() => ({ error: null })),
|
|
7
|
+
RequestBuilder: jest.fn(() => ({
|
|
8
|
+
setEntryContext: jest.fn().mockReturnThis(),
|
|
9
|
+
setScreenContext: jest.fn().mockReturnThis(),
|
|
10
|
+
setUrl: jest.fn().mockReturnThis(),
|
|
11
|
+
buildAxiosRequest: jest.fn().mockResolvedValue(undefined),
|
|
12
|
+
call: jest.fn().mockResolvedValue({
|
|
13
|
+
response: {
|
|
14
|
+
entry: [],
|
|
15
|
+
extensions: { dynamic_collection_options: { operations: "add" } },
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
})),
|
|
19
|
+
}));
|
|
20
|
+
|
|
5
21
|
jest.mock("../../../modalState/store", () => ({
|
|
6
22
|
openBottomSheetModal: jest.fn(),
|
|
7
23
|
}));
|
|
@@ -165,6 +181,62 @@ describe("openBottomSheetAction inline items", () => {
|
|
|
165
181
|
expect(menu.content.emptyMessage).toBe("Queued items will be added here");
|
|
166
182
|
});
|
|
167
183
|
|
|
184
|
+
it("forwards content.operationButtons onto the menu", async () => {
|
|
185
|
+
const result = await openBottomSheetAction({
|
|
186
|
+
type: "openBottomSheet",
|
|
187
|
+
options: {
|
|
188
|
+
header: { title: "Playlists" },
|
|
189
|
+
content: {
|
|
190
|
+
items: [{ id: "p1", title: "Playlist 1" }],
|
|
191
|
+
operationButtons: {
|
|
192
|
+
add: {
|
|
193
|
+
title: "Create New Playlist",
|
|
194
|
+
iconURL: "https://example.com/add.png",
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
} as any);
|
|
200
|
+
|
|
201
|
+
expect(result).toBe(ActionResult.Success);
|
|
202
|
+
|
|
203
|
+
const [menu] = (modalOrchestrator.open as jest.Mock).mock.calls[0];
|
|
204
|
+
|
|
205
|
+
expect(menu.content.operationButtons).toEqual({
|
|
206
|
+
add: {
|
|
207
|
+
title: "Create New Playlist",
|
|
208
|
+
iconURL: "https://example.com/add.png",
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("preserves Add presentation when loading itemsUrl content", async () => {
|
|
214
|
+
const result = await openBottomSheetAction({
|
|
215
|
+
type: "openBottomSheet",
|
|
216
|
+
options: {
|
|
217
|
+
content: {
|
|
218
|
+
itemsUrl: "https://example.com/collections",
|
|
219
|
+
operationButtons: {
|
|
220
|
+
add: {
|
|
221
|
+
title: "Create Collection",
|
|
222
|
+
iconURL: "file:///bundled-add.png",
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
expect(result).toBe(ActionResult.Success);
|
|
230
|
+
const [menu] = (modalOrchestrator.open as jest.Mock).mock.calls[0];
|
|
231
|
+
|
|
232
|
+
expect(menu.content).toMatchObject({
|
|
233
|
+
operationButtons: {
|
|
234
|
+
add: { title: "Create Collection", iconURL: "file:///bundled-add.png" },
|
|
235
|
+
},
|
|
236
|
+
dynamicCollection: { operations: ["add"] },
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
168
240
|
it("pushes a new sheet by default even when another sheet is already open", async () => {
|
|
169
241
|
(modalOrchestrator as any).stackSize = 1;
|
|
170
242
|
|
|
@@ -27,12 +27,10 @@ export const screenToggleFlagAction: ActionHandler<
|
|
|
27
27
|
const screenRoute = context?.screenRoute;
|
|
28
28
|
const screenStateStore = context?.screenStateStore;
|
|
29
29
|
|
|
30
|
-
await screenToggleFlag(
|
|
30
|
+
return await screenToggleFlag(
|
|
31
31
|
screenRoute,
|
|
32
32
|
screenStateStore,
|
|
33
33
|
{ entry: context?.entry, options: action.options },
|
|
34
34
|
action
|
|
35
35
|
);
|
|
36
|
-
|
|
37
|
-
return ActionResult.Success;
|
|
38
36
|
};
|
|
@@ -47,6 +47,11 @@ function makeMultiSelect(feed: ZappFeed, key, decoratedFeed) {
|
|
|
47
47
|
? "sessionStorageToggleFlag"
|
|
48
48
|
: "localStorageToggleFlag";
|
|
49
49
|
|
|
50
|
+
// the toggle actions read their limit from their own options
|
|
51
|
+
const maxItems = Number(
|
|
52
|
+
decoratedFeed.extensions?.preference_editor_options?.max_items
|
|
53
|
+
);
|
|
54
|
+
|
|
50
55
|
decoratedFeed.entry?.forEach((entry: ZappEntry) => {
|
|
51
56
|
entry.type.value = "action";
|
|
52
57
|
entry.id = entry.extensions?.tag || entry.id;
|
|
@@ -59,6 +64,7 @@ function makeMultiSelect(feed: ZappFeed, key, decoratedFeed) {
|
|
|
59
64
|
type: actionType,
|
|
60
65
|
options: {
|
|
61
66
|
key,
|
|
67
|
+
...(maxItems > 0 && { max_items: maxItems }),
|
|
62
68
|
},
|
|
63
69
|
},
|
|
64
70
|
],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextKeysManager
|
|
1
|
+
import { ContextKeysManager } from "../..";
|
|
2
2
|
|
|
3
3
|
describe("Context Keys Manager - getKey", () => {
|
|
4
4
|
it("returns null if key is invalid", async () => {
|
|
@@ -34,8 +34,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
34
34
|
secureStorage: mockedSecureStorage,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
const getKeyByReference = jest.spyOn(contextManager, "getKeyByReference");
|
|
38
|
-
|
|
39
37
|
// run
|
|
40
38
|
const result = await contextManager.getKey(invalidKey);
|
|
41
39
|
|
|
@@ -50,7 +48,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
50
48
|
data: { key: invalidKey },
|
|
51
49
|
});
|
|
52
50
|
|
|
53
|
-
expect(getKeyByReference).not.toHaveBeenCalled();
|
|
54
51
|
expect(mockedSessionStorage.getItem).not.toHaveBeenCalled();
|
|
55
52
|
expect(mockedLocalStorage.getItem).not.toHaveBeenCalled();
|
|
56
53
|
expect(mockedSecureStorage.getItem).not.toHaveBeenCalled();
|
|
@@ -90,10 +87,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
90
87
|
secureStorage: mockedSecureStorage,
|
|
91
88
|
});
|
|
92
89
|
|
|
93
|
-
const getKeyByReference = jest
|
|
94
|
-
.spyOn(contextManager, "getKeyByReference")
|
|
95
|
-
.mockResolvedValueOnce(NOTHING);
|
|
96
|
-
|
|
97
90
|
// run
|
|
98
91
|
const result = await contextManager.getKey(key);
|
|
99
92
|
|
|
@@ -107,8 +100,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
107
100
|
data: { key },
|
|
108
101
|
});
|
|
109
102
|
|
|
110
|
-
expect(getKeyByReference).toHaveBeenCalledWith("key", "namespace");
|
|
111
|
-
|
|
112
103
|
expect(mockedSessionStorage.getItem).toHaveBeenCalledWith(
|
|
113
104
|
"key",
|
|
114
105
|
"namespace"
|
|
@@ -152,10 +143,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
152
143
|
secureStorage: mockedSecureStorage,
|
|
153
144
|
});
|
|
154
145
|
|
|
155
|
-
const getKeyByReference = jest
|
|
156
|
-
.spyOn(contextManager, "getKeyByReference")
|
|
157
|
-
.mockResolvedValueOnce(NOTHING);
|
|
158
|
-
|
|
159
146
|
// run
|
|
160
147
|
const result = await contextManager.getKey(key);
|
|
161
148
|
|
|
@@ -169,8 +156,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
169
156
|
data: { key },
|
|
170
157
|
});
|
|
171
158
|
|
|
172
|
-
expect(getKeyByReference).toHaveBeenCalledWith("key", "namespace");
|
|
173
|
-
|
|
174
159
|
expect(mockedSessionStorage.getItem).toHaveBeenCalledWith(
|
|
175
160
|
"key",
|
|
176
161
|
"namespace"
|
|
@@ -214,10 +199,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
214
199
|
secureStorage: mockedSecureStorage,
|
|
215
200
|
});
|
|
216
201
|
|
|
217
|
-
const getKeyByReference = jest
|
|
218
|
-
.spyOn(contextManager, "getKeyByReference")
|
|
219
|
-
.mockResolvedValueOnce(NOTHING);
|
|
220
|
-
|
|
221
202
|
// run
|
|
222
203
|
const result = await contextManager.getKey(key);
|
|
223
204
|
|
|
@@ -231,8 +212,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
231
212
|
data: { key },
|
|
232
213
|
});
|
|
233
214
|
|
|
234
|
-
expect(getKeyByReference).toHaveBeenCalledWith("key", "namespace");
|
|
235
|
-
|
|
236
215
|
expect(mockedSessionStorage.getItem).toHaveBeenCalledWith(
|
|
237
216
|
"key",
|
|
238
217
|
"namespace"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextKeysManager
|
|
1
|
+
import { ContextKeysManager } from "../../..";
|
|
2
2
|
|
|
3
3
|
describe("Context Keys Manager - getKey", () => {
|
|
4
4
|
it("returns value if found in session-storage", async () => {
|
|
@@ -35,10 +35,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
35
35
|
secureStorage: mockedSecureStorage,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
const getKeyByReference = jest
|
|
39
|
-
.spyOn(contextManager, "getKeyByReference")
|
|
40
|
-
.mockResolvedValueOnce(NOTHING);
|
|
41
|
-
|
|
42
38
|
// run
|
|
43
39
|
const result = await contextManager.getKey(key);
|
|
44
40
|
|
|
@@ -47,8 +43,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
47
43
|
|
|
48
44
|
expect(mockedLogger.warn).not.toHaveBeenCalled();
|
|
49
45
|
|
|
50
|
-
expect(getKeyByReference).toHaveBeenCalledWith("key", "namespace");
|
|
51
|
-
|
|
52
46
|
expect(mockedSessionStorage.getItem).toHaveBeenCalledWith(
|
|
53
47
|
"key",
|
|
54
48
|
"namespace"
|
|
@@ -92,10 +86,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
92
86
|
secureStorage: mockedSecureStorage,
|
|
93
87
|
});
|
|
94
88
|
|
|
95
|
-
const getKeyByReference = jest
|
|
96
|
-
.spyOn(contextManager, "getKeyByReference")
|
|
97
|
-
.mockResolvedValueOnce(NOTHING);
|
|
98
|
-
|
|
99
89
|
// run
|
|
100
90
|
const result = await contextManager.getKey(key);
|
|
101
91
|
|
|
@@ -104,8 +94,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
104
94
|
|
|
105
95
|
expect(mockedLogger.warn).not.toHaveBeenCalled();
|
|
106
96
|
|
|
107
|
-
expect(getKeyByReference).toHaveBeenCalledWith("key", "namespace");
|
|
108
|
-
|
|
109
97
|
expect(mockedSessionStorage.getItem).toHaveBeenCalledWith(
|
|
110
98
|
"key",
|
|
111
99
|
"namespace"
|
|
@@ -149,10 +137,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
149
137
|
secureStorage: mockedSecureStorage,
|
|
150
138
|
});
|
|
151
139
|
|
|
152
|
-
const getKeyByReference = jest
|
|
153
|
-
.spyOn(contextManager, "getKeyByReference")
|
|
154
|
-
.mockResolvedValueOnce(NOTHING);
|
|
155
|
-
|
|
156
140
|
// run
|
|
157
141
|
const result = await contextManager.getKey(key);
|
|
158
142
|
|
|
@@ -161,8 +145,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
161
145
|
|
|
162
146
|
expect(mockedLogger.warn).not.toHaveBeenCalled();
|
|
163
147
|
|
|
164
|
-
expect(getKeyByReference).toHaveBeenCalledWith("key", "namespace");
|
|
165
|
-
|
|
166
148
|
expect(mockedSessionStorage.getItem).toHaveBeenCalledWith(
|
|
167
149
|
"key",
|
|
168
150
|
"namespace"
|
|
@@ -209,10 +191,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
209
191
|
secureStorage: mockedSecureStorage,
|
|
210
192
|
});
|
|
211
193
|
|
|
212
|
-
const getKeyByReference = jest
|
|
213
|
-
.spyOn(contextManager, "getKeyByReference")
|
|
214
|
-
.mockResolvedValueOnce(NOTHING);
|
|
215
|
-
|
|
216
194
|
// run
|
|
217
195
|
const result = await contextManager.getKey(key);
|
|
218
196
|
|
|
@@ -221,8 +199,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
221
199
|
|
|
222
200
|
expect(mockedLogger.warn).not.toHaveBeenCalled();
|
|
223
201
|
|
|
224
|
-
expect(getKeyByReference).toHaveBeenCalledWith("key", "namespace");
|
|
225
|
-
|
|
226
202
|
expect(mockedSessionStorage.getItem).toHaveBeenCalledWith(
|
|
227
203
|
"key",
|
|
228
204
|
"namespace"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextKeysManager
|
|
1
|
+
import { ContextKeysManager } from "../../..";
|
|
2
2
|
import { DEFAULT_NAMESPACE } from "../../../consts";
|
|
3
3
|
|
|
4
4
|
describe("Context Keys Manager - getKey", () => {
|
|
@@ -36,10 +36,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
36
36
|
secureStorage: mockedSecureStorage,
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
const getKeyByReference = jest
|
|
40
|
-
.spyOn(contextManager, "getKeyByReference")
|
|
41
|
-
.mockResolvedValueOnce(NOTHING);
|
|
42
|
-
|
|
43
39
|
// run
|
|
44
40
|
const result = await contextManager.getKey(key);
|
|
45
41
|
|
|
@@ -48,8 +44,6 @@ describe("Context Keys Manager - getKey", () => {
|
|
|
48
44
|
|
|
49
45
|
expect(mockedLogger.warn).not.toHaveBeenCalled();
|
|
50
46
|
|
|
51
|
-
expect(getKeyByReference).toHaveBeenCalledWith("key", DEFAULT_NAMESPACE);
|
|
52
|
-
|
|
53
47
|
expect(mockedSessionStorage.getItem).toHaveBeenCalledWith(
|
|
54
48
|
"key",
|
|
55
49
|
DEFAULT_NAMESPACE
|
|
@@ -34,11 +34,6 @@ describe("Context Keys Manager - removeKey", () => {
|
|
|
34
34
|
secureStorage: mockedSecureStorage,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
const removeReferenceForKey = jest.spyOn(
|
|
38
|
-
contextManager,
|
|
39
|
-
"removeReferenceForKey"
|
|
40
|
-
);
|
|
41
|
-
|
|
42
37
|
// run
|
|
43
38
|
const result = await contextManager.removeKey(key);
|
|
44
39
|
|
|
@@ -51,8 +46,6 @@ describe("Context Keys Manager - removeKey", () => {
|
|
|
51
46
|
data: { key },
|
|
52
47
|
});
|
|
53
48
|
|
|
54
|
-
expect(removeReferenceForKey).not.toHaveBeenCalled();
|
|
55
|
-
|
|
56
49
|
expect(mockedSessionStorage.removeItem).not.toHaveBeenCalled();
|
|
57
50
|
expect(mockedLocalStorage.removeItem).not.toHaveBeenCalled();
|
|
58
51
|
expect(mockedSecureStorage.removeItem).not.toHaveBeenCalled();
|
|
@@ -92,10 +85,6 @@ describe("Context Keys Manager - removeKey", () => {
|
|
|
92
85
|
secureStorage: mockedSecureStorage,
|
|
93
86
|
});
|
|
94
87
|
|
|
95
|
-
const removeReferenceForKey = jest
|
|
96
|
-
.spyOn(contextManager, "removeReferenceForKey")
|
|
97
|
-
.mockResolvedValueOnce(true);
|
|
98
|
-
|
|
99
88
|
// run
|
|
100
89
|
const result = await contextManager.removeKey(key);
|
|
101
90
|
|
|
@@ -107,8 +96,6 @@ describe("Context Keys Manager - removeKey", () => {
|
|
|
107
96
|
data: { key },
|
|
108
97
|
});
|
|
109
98
|
|
|
110
|
-
expect(removeReferenceForKey).toHaveBeenCalledWith("key", "namespace");
|
|
111
|
-
|
|
112
99
|
expect(mockedSessionStorage.removeItem).toHaveBeenCalledWith(
|
|
113
100
|
"key",
|
|
114
101
|
"namespace"
|
|
@@ -159,10 +146,6 @@ describe("Context Keys Manager - removeKey", () => {
|
|
|
159
146
|
secureStorage: mockedSecureStorage,
|
|
160
147
|
});
|
|
161
148
|
|
|
162
|
-
const removeReferenceForKey = jest
|
|
163
|
-
.spyOn(contextManager, "removeReferenceForKey")
|
|
164
|
-
.mockResolvedValueOnce(true);
|
|
165
|
-
|
|
166
149
|
// run
|
|
167
150
|
const result = await contextManager.removeKey(key);
|
|
168
151
|
|
|
@@ -174,8 +157,6 @@ describe("Context Keys Manager - removeKey", () => {
|
|
|
174
157
|
data: { key },
|
|
175
158
|
});
|
|
176
159
|
|
|
177
|
-
expect(removeReferenceForKey).toHaveBeenCalledWith("key", "namespace");
|
|
178
|
-
|
|
179
160
|
expect(mockedSessionStorage.removeItem).toHaveBeenCalledWith(
|
|
180
161
|
"key",
|
|
181
162
|
"namespace"
|
|
@@ -226,10 +207,6 @@ describe("Context Keys Manager - removeKey", () => {
|
|
|
226
207
|
secureStorage: mockedSecureStorage,
|
|
227
208
|
});
|
|
228
209
|
|
|
229
|
-
const removeReferenceForKey = jest
|
|
230
|
-
.spyOn(contextManager, "removeReferenceForKey")
|
|
231
|
-
.mockResolvedValueOnce(true);
|
|
232
|
-
|
|
233
210
|
// run
|
|
234
211
|
const result = await contextManager.removeKey(key);
|
|
235
212
|
|
|
@@ -241,8 +218,6 @@ describe("Context Keys Manager - removeKey", () => {
|
|
|
241
218
|
data: { key },
|
|
242
219
|
});
|
|
243
220
|
|
|
244
|
-
expect(removeReferenceForKey).toHaveBeenCalledWith("key", "namespace");
|
|
245
|
-
|
|
246
221
|
expect(mockedSessionStorage.removeItem).toHaveBeenCalledWith(
|
|
247
222
|
"key",
|
|
248
223
|
"namespace"
|
|
@@ -34,10 +34,6 @@ describe("Context Keys Manager - removeKey", () => {
|
|
|
34
34
|
secureStorage: mockedSecureStorage,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
const removeReferenceForKey = jest
|
|
38
|
-
.spyOn(contextManager, "removeReferenceForKey")
|
|
39
|
-
.mockResolvedValueOnce(true);
|
|
40
|
-
|
|
41
37
|
// run
|
|
42
38
|
const result = await contextManager.removeKey(key);
|
|
43
39
|
|
|
@@ -46,8 +42,6 @@ describe("Context Keys Manager - removeKey", () => {
|
|
|
46
42
|
|
|
47
43
|
expect(mockedLogger.warn).not.toHaveBeenCalled();
|
|
48
44
|
|
|
49
|
-
expect(removeReferenceForKey).toHaveBeenCalledWith("key", "namespace");
|
|
50
|
-
|
|
51
45
|
expect(mockedSessionStorage.removeItem).toHaveBeenCalledWith(
|
|
52
46
|
"key",
|
|
53
47
|
"namespace"
|