@applicaster/zapp-react-native-utils 15.1.13-alpha.1034774223 → 15.1.13
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/ActionExecutor.ts +2 -40
- package/actionsExecutor/ActionExecutorContext.tsx +16 -70
- package/actionsExecutor/actions/index.ts +0 -4
- package/actionsExecutor/actions/refreshComponent.ts +0 -6
- package/actionsExecutor/actions/sendCloudEvent.ts +1 -6
- package/actionsExecutor/consts.ts +0 -23
- package/actionsExecutor/types.ts +1 -1
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +2 -5
- package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +2 -55
- package/appUtils/playerManager/OverlayObserver/utils.ts +20 -51
- package/arrayUtils/index.ts +0 -79
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +0 -21
- package/configurationUtils/manifestKeyParser.ts +10 -50
- package/manifestUtils/defaultManifestConfigurations/player.js +1 -22
- package/manifestUtils/index.js +0 -3
- package/modalState/__tests__/index.test.ts +1 -30
- package/modalState/index.ts +83 -35
- package/package.json +2 -2
- package/playerUtils/__tests__/getPlayerActionButtons.test.ts +54 -0
- package/playerUtils/getPlayerActionButtons.ts +17 -0
- package/playerUtils/index.ts +1 -17
- package/reactHooks/actions/index.ts +2 -67
- package/reactHooks/cell-click/__tests__/index.test.js +64 -0
- package/reactHooks/cell-click/index.ts +21 -14
- package/reactHooks/usePluginConfiguration.ts +3 -6
- package/uiActionsRegistrator/index.ts +203 -25
- package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +0 -25
- package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +0 -88
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +0 -76
- package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +0 -212
- package/actionsExecutor/actions/dismissBottomSheet.ts +0 -23
- package/actionsExecutor/actions/openBottomSheet.ts +0 -325
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +0 -4
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +0 -4
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +0 -11
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +0 -4
- package/arrayUtils/__tests__/reorderByIds.test.ts +0 -50
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +0 -260
- package/configurationUtils/modalBlocksParser.ts +0 -296
- package/entryActions/__tests__/buildEntryActions.test.ts +0 -156
- package/entryActions/aliasPresentation.ts +0 -124
- package/entryActions/buildEntryActions.ts +0 -166
- package/entryActions/index.ts +0 -17
- package/entryActions/types.ts +0 -39
- package/manifestUtils/modalBlocks.js +0 -304
- package/modalState/ContentViewModel.ts +0 -113
- package/modalState/EditableCollection.ts +0 -17
- package/modalState/EditableCollectionRegistry.ts +0 -51
- package/modalState/ModalOrchestrator.ts +0 -211
- package/modalState/RemoteEditableCollection.ts +0 -227
- package/modalState/__tests__/ContentViewModel.editable.test.ts +0 -69
- package/modalState/__tests__/ContentViewModel.test.ts +0 -165
- package/modalState/__tests__/EditableCollectionRegistry.test.ts +0 -112
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +0 -47
- package/modalState/__tests__/RemoteEditableCollection.test.ts +0 -326
- package/modalState/__tests__/useBottomSheetContent.test.ts +0 -349
- package/modalState/store.ts +0 -102
- package/modalState/types.ts +0 -159
- package/modalState/useBottomSheetContent.ts +0 -104
- package/playerUtils/__tests__/resolvePlayerActions.test.ts +0 -138
- package/playerUtils/resolvePlayerActions.ts +0 -71
- package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +0 -93
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +0 -107
- package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +0 -52
- package/uiActionsRegistrator/registry.ts +0 -335
- package/uiActionsRegistrator/resolveActionIdentifiers.ts +0 -100
- package/uiActionsRegistrator/usableActionItems.ts +0 -66
- /package/reactHooks/actions/__tests__/{index.test.tsx → index.test.js} +0 -0
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { resolvePlayerActions } from "../resolvePlayerActions";
|
|
2
|
-
import { selectActionButtons } from "../../conf/player/selectors";
|
|
3
|
-
import { uiActionsRegistry } from "../../uiActionsRegistrator";
|
|
4
|
-
|
|
5
|
-
jest.mock("../../conf/player/selectors", () => ({
|
|
6
|
-
selectActionButtons: jest.fn(),
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
const action = (identifier: string) =>
|
|
10
|
-
({ identifier, action: { invokeAction: jest.fn() } }) as any;
|
|
11
|
-
|
|
12
|
-
describe("resolvePlayerActions", () => {
|
|
13
|
-
const entry = {
|
|
14
|
-
id: "e1",
|
|
15
|
-
extensions: {
|
|
16
|
-
entry_action: [
|
|
17
|
-
{ button: { alias: "add_to_playlist" }, actions: [{ type: "test" }] },
|
|
18
|
-
{ button: { alias: "add_to_queue" }, actions: [{ type: "test" }] },
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// The entry's own actions never reach the registry; the caller expands them.
|
|
24
|
-
const expandEntryActions = jest.fn(() => [
|
|
25
|
-
action("entry_action_0"),
|
|
26
|
-
action("entry_action_1"),
|
|
27
|
-
]);
|
|
28
|
-
|
|
29
|
-
beforeEach(() => {
|
|
30
|
-
expandEntryActions.mockClear();
|
|
31
|
-
|
|
32
|
-
jest
|
|
33
|
-
.spyOn(uiActionsRegistry, "getActions")
|
|
34
|
-
.mockImplementation((name) => [action(name)]);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
afterEach(() => {
|
|
38
|
-
jest.restoreAllMocks();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("expands entry_actions through the caller and keeps config order", () => {
|
|
42
|
-
(selectActionButtons as jest.Mock).mockReturnValue(
|
|
43
|
-
"entry_actions,local_storage_favourites_action,offline-content-button"
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const result = resolvePlayerActions({
|
|
47
|
-
configuration: {},
|
|
48
|
-
entry,
|
|
49
|
-
expandEntryActions,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
expect(expandEntryActions).toHaveBeenCalledWith(entry);
|
|
53
|
-
|
|
54
|
-
expect(uiActionsRegistry.getActions).not.toHaveBeenCalledWith(
|
|
55
|
-
"entry_actions",
|
|
56
|
-
entry
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
expect(result.map((item) => item.identifier)).toEqual([
|
|
60
|
-
"entry_action_0",
|
|
61
|
-
"entry_action_1",
|
|
62
|
-
"local_storage_favourites_action",
|
|
63
|
-
"offline-content-button",
|
|
64
|
-
]);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it.each([undefined, null, ""])(
|
|
68
|
-
"resolves nothing when the config is %p",
|
|
69
|
-
(configured) => {
|
|
70
|
-
(selectActionButtons as jest.Mock).mockReturnValue(configured);
|
|
71
|
-
|
|
72
|
-
expect(
|
|
73
|
-
resolvePlayerActions({ configuration: {}, entry, expandEntryActions })
|
|
74
|
-
).toEqual([]);
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
it("does not cap the resolved list at two items", () => {
|
|
79
|
-
(selectActionButtons as jest.Mock).mockReturnValue("a,b,c");
|
|
80
|
-
|
|
81
|
-
expect(
|
|
82
|
-
resolvePlayerActions({
|
|
83
|
-
configuration: {},
|
|
84
|
-
entry,
|
|
85
|
-
expandEntryActions,
|
|
86
|
-
}).map((item) => item.identifier)
|
|
87
|
-
).toEqual(["a", "b", "c"]);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("has no special case for any plugin identifier", () => {
|
|
91
|
-
(selectActionButtons as jest.Mock).mockReturnValue(
|
|
92
|
-
"open-modal-bottom-sheet-cell-action,local_storage_favourites_action"
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
expect(
|
|
96
|
-
resolvePlayerActions({
|
|
97
|
-
configuration: {},
|
|
98
|
-
entry,
|
|
99
|
-
expandEntryActions,
|
|
100
|
-
}).map((item) => item.identifier)
|
|
101
|
-
).toEqual([
|
|
102
|
-
"open-modal-bottom-sheet-cell-action",
|
|
103
|
-
"local_storage_favourites_action",
|
|
104
|
-
]);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("collapses a repeated identifier in the config string", () => {
|
|
108
|
-
(selectActionButtons as jest.Mock).mockReturnValue(
|
|
109
|
-
"favorites,favorites,share"
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
expect(
|
|
113
|
-
resolvePlayerActions({
|
|
114
|
-
configuration: {},
|
|
115
|
-
entry,
|
|
116
|
-
expandEntryActions,
|
|
117
|
-
}).map((item) => item.identifier)
|
|
118
|
-
).toEqual(["favorites", "share"]);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("drops resolved items that cannot be invoked", () => {
|
|
122
|
-
(selectActionButtons as jest.Mock).mockReturnValue("broken,share");
|
|
123
|
-
|
|
124
|
-
(uiActionsRegistry.getActions as jest.Mock).mockImplementation((name) =>
|
|
125
|
-
name === "broken"
|
|
126
|
-
? [{ identifier: "broken" } as any]
|
|
127
|
-
: [action(name as string)]
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
expect(
|
|
131
|
-
resolvePlayerActions({
|
|
132
|
-
configuration: {},
|
|
133
|
-
entry,
|
|
134
|
-
expandEntryActions,
|
|
135
|
-
}).map((item) => item.identifier)
|
|
136
|
-
).toEqual(["share"]);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { selectActionButtons } from "../conf/player/selectors";
|
|
2
|
-
import {
|
|
3
|
-
usableActionItems,
|
|
4
|
-
RegisteredAction,
|
|
5
|
-
resolveActionIdentifiers,
|
|
6
|
-
} from "../uiActionsRegistrator";
|
|
7
|
-
|
|
8
|
-
export type ResolvePlayerActionsParams = {
|
|
9
|
-
configuration: any;
|
|
10
|
-
entry: ZappEntry | ZappFeed;
|
|
11
|
-
/** Expands the `entry_actions` token; see `resolveActionIdentifiers`. */
|
|
12
|
-
expandEntryActions?: (entry: ZappEntry | ZappFeed) => RegisteredAction[];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The player's action buttons, resolved against the entry.
|
|
17
|
-
*
|
|
18
|
-
* Every `player_action_buttons` token goes through `uiActionsRegistry`, except
|
|
19
|
-
* `entry_actions`, which the caller expands from the entry itself. The list is
|
|
20
|
-
* not capped; the overlay decides how many fit and sends the rest to the sheet.
|
|
21
|
-
*/
|
|
22
|
-
export function resolvePlayerActions({
|
|
23
|
-
configuration,
|
|
24
|
-
entry,
|
|
25
|
-
expandEntryActions,
|
|
26
|
-
}: ResolvePlayerActionsParams): RegisteredAction[] {
|
|
27
|
-
const buttonsString = selectActionButtons(configuration);
|
|
28
|
-
|
|
29
|
-
if (!buttonsString) {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Deduped at the source: `player_action_buttons` is a hand-typed string, so
|
|
34
|
-
// the same identifier can legitimately appear twice. Left alone, a repeat
|
|
35
|
-
// would be counted twice against the inline limit, rendered twice on the
|
|
36
|
-
// overlay, and collide as a React key. Items with no `invokeAction` are
|
|
37
|
-
// dropped here too - they can never do anything.
|
|
38
|
-
return usableActionItems(
|
|
39
|
-
resolveActionIdentifiers({
|
|
40
|
-
identifiers: buttonsString,
|
|
41
|
-
entry,
|
|
42
|
-
expandEntryActions,
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** One control on the player overlay, before overflow is applied. */
|
|
48
|
-
export type ActionButtonDescriptor =
|
|
49
|
-
| { kind: "subtitle" }
|
|
50
|
-
| { kind: "close" }
|
|
51
|
-
| { kind: "airplay" }
|
|
52
|
-
| { kind: "action"; action: RegisteredAction };
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The Overflow control, produced by `splitOverflow` when more content actions
|
|
56
|
-
* resolve than fit on the overlay.
|
|
57
|
-
*/
|
|
58
|
-
export type OverflowDescriptor = {
|
|
59
|
-
kind: "overflow";
|
|
60
|
-
/**
|
|
61
|
-
* Every content action, the overlay companion included. An overlay button
|
|
62
|
-
* renders nothing when its action has no icon, so the companion needs the
|
|
63
|
-
* sheet as a second home or it could be reachable from nowhere.
|
|
64
|
-
*/
|
|
65
|
-
additionalActions: RegisteredAction[];
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/** What the overlay actually renders, once overflow has been applied. */
|
|
69
|
-
export type PlayerControlDescriptor =
|
|
70
|
-
| ActionButtonDescriptor
|
|
71
|
-
| OverflowDescriptor;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
parseActionIdentifiers,
|
|
3
|
-
resolveActionIdentifiers,
|
|
4
|
-
} from "../resolveActionIdentifiers";
|
|
5
|
-
import { uiActionsRegistry } from "../registry";
|
|
6
|
-
|
|
7
|
-
const action = (identifier: string) =>
|
|
8
|
-
({ identifier, action: { invokeAction: jest.fn() } }) as any;
|
|
9
|
-
|
|
10
|
-
describe("parseActionIdentifiers", () => {
|
|
11
|
-
it("parses comma-separated identifiers", () => {
|
|
12
|
-
expect(parseActionIdentifiers(" a, b , ,c ")).toEqual(["a", "b", "c"]);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("parses identifier arrays", () => {
|
|
16
|
-
expect(parseActionIdentifiers([" a ", "", "b", " ", "c"])).toEqual([
|
|
17
|
-
"a",
|
|
18
|
-
"b",
|
|
19
|
-
"c",
|
|
20
|
-
]);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("returns empty array for nil config", () => {
|
|
24
|
-
expect(parseActionIdentifiers(null)).toEqual([]);
|
|
25
|
-
expect(parseActionIdentifiers(undefined)).toEqual([]);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe("resolveActionIdentifiers", () => {
|
|
30
|
-
const entry = { id: "entry-1" } as any;
|
|
31
|
-
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
jest
|
|
34
|
-
.spyOn(uiActionsRegistry, "getActions")
|
|
35
|
-
.mockImplementation((identifier) => [action(identifier)] as any);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
afterEach(() => {
|
|
39
|
-
jest.restoreAllMocks();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("resolves through registry by default", () => {
|
|
43
|
-
const result = resolveActionIdentifiers({
|
|
44
|
-
identifiers: "favorites,share",
|
|
45
|
-
entry,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
expect(result.map((item) => item.identifier)).toEqual([
|
|
49
|
-
"favorites",
|
|
50
|
-
"share",
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
|
-
expect(uiActionsRegistry.getActions).toHaveBeenCalledWith(
|
|
54
|
-
"favorites",
|
|
55
|
-
entry
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
expect(uiActionsRegistry.getActions).toHaveBeenCalledWith("share", entry);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("expands entry_actions through the caller, not the registry", () => {
|
|
62
|
-
const expanded = [action("entry_action_0"), action("entry_action_1")];
|
|
63
|
-
const expandEntryActions = jest.fn(() => expanded);
|
|
64
|
-
|
|
65
|
-
const unregister = uiActionsRegistry.registerAction("share", {
|
|
66
|
-
invokeAction: jest.fn(),
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
const result = resolveActionIdentifiers({
|
|
71
|
-
identifiers: "entry_actions,share",
|
|
72
|
-
entry,
|
|
73
|
-
expandEntryActions,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
expect(expandEntryActions).toHaveBeenCalledWith(entry);
|
|
77
|
-
|
|
78
|
-
expect(result.map((item) => item.identifier)).toEqual([
|
|
79
|
-
"entry_action_0",
|
|
80
|
-
"entry_action_1",
|
|
81
|
-
"share",
|
|
82
|
-
]);
|
|
83
|
-
} finally {
|
|
84
|
-
unregister();
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("resolves nothing for entry_actions when the caller cannot expand it", () => {
|
|
89
|
-
expect(
|
|
90
|
-
resolveActionIdentifiers({ identifiers: "entry_actions", entry })
|
|
91
|
-
).toEqual([]);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { isActionAvailableFor, uiActionsRegistry } from "../registry";
|
|
2
|
-
|
|
3
|
-
const value = { invokeAction: jest.fn() };
|
|
4
|
-
|
|
5
|
-
describe("uiActionsRegistry.subscribe", () => {
|
|
6
|
-
it("fires on registration and on unregistration", () => {
|
|
7
|
-
const listener = jest.fn();
|
|
8
|
-
const unsubscribe = uiActionsRegistry.subscribe(listener);
|
|
9
|
-
|
|
10
|
-
const unregister = uiActionsRegistry.registerAction("late-action", value);
|
|
11
|
-
|
|
12
|
-
expect(listener).toHaveBeenCalledTimes(1);
|
|
13
|
-
|
|
14
|
-
unregister();
|
|
15
|
-
|
|
16
|
-
expect(listener).toHaveBeenCalledTimes(2);
|
|
17
|
-
|
|
18
|
-
unsubscribe();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("lets a listener see the action it was told about", () => {
|
|
22
|
-
let seen: string[] = [];
|
|
23
|
-
|
|
24
|
-
const unsubscribe = uiActionsRegistry.subscribe(() => {
|
|
25
|
-
seen = uiActionsRegistry
|
|
26
|
-
.getActions("late-action", { id: "e1" } as any)
|
|
27
|
-
.map((item) => item.identifier);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const unregister = uiActionsRegistry.registerAction("late-action", value);
|
|
31
|
-
|
|
32
|
-
expect(seen).toEqual(["late-action"]);
|
|
33
|
-
|
|
34
|
-
unregister();
|
|
35
|
-
unsubscribe();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("stops calling a listener once unsubscribed", () => {
|
|
39
|
-
const listener = jest.fn();
|
|
40
|
-
|
|
41
|
-
uiActionsRegistry.subscribe(listener)();
|
|
42
|
-
|
|
43
|
-
uiActionsRegistry.registerAction("another-action", value)();
|
|
44
|
-
|
|
45
|
-
expect(listener).not.toHaveBeenCalled();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("survives a listener that unsubscribes itself while being notified", () => {
|
|
49
|
-
const other = jest.fn();
|
|
50
|
-
|
|
51
|
-
const unsubscribeOther = uiActionsRegistry.subscribe(other);
|
|
52
|
-
|
|
53
|
-
const unsubscribeSelf = uiActionsRegistry.subscribe(() => {
|
|
54
|
-
unsubscribeSelf();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
expect(() =>
|
|
58
|
-
uiActionsRegistry.registerAction("self-removing", value)()
|
|
59
|
-
).not.toThrow();
|
|
60
|
-
|
|
61
|
-
expect(other).toHaveBeenCalled();
|
|
62
|
-
|
|
63
|
-
unsubscribeOther();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe("isActionAvailableFor", () => {
|
|
68
|
-
const entry = { id: "e1" } as any;
|
|
69
|
-
|
|
70
|
-
it("shows an action that states no opinion", () => {
|
|
71
|
-
expect(isActionAvailableFor({ invokeAction: jest.fn() }, entry)).toBe(true);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it.each([
|
|
75
|
-
["isSupportDownloads"],
|
|
76
|
-
["isActionSupported"],
|
|
77
|
-
["isActionAvailable"],
|
|
78
|
-
])("honours %s", (predicate) => {
|
|
79
|
-
expect(
|
|
80
|
-
isActionAvailableFor(
|
|
81
|
-
{ invokeAction: jest.fn(), [predicate]: () => false } as any,
|
|
82
|
-
entry
|
|
83
|
-
)
|
|
84
|
-
).toBe(false);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("asks only the first predicate the action defines", () => {
|
|
88
|
-
const isActionAvailable = jest.fn(() => true);
|
|
89
|
-
|
|
90
|
-
expect(
|
|
91
|
-
isActionAvailableFor(
|
|
92
|
-
{
|
|
93
|
-
invokeAction: jest.fn(),
|
|
94
|
-
isSupportDownloads: () => false,
|
|
95
|
-
isActionAvailable,
|
|
96
|
-
} as any,
|
|
97
|
-
entry
|
|
98
|
-
)
|
|
99
|
-
).toBe(false);
|
|
100
|
-
|
|
101
|
-
expect(isActionAvailable).not.toHaveBeenCalled();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("treats a missing action as unavailable-free", () => {
|
|
105
|
-
expect(isActionAvailableFor(undefined, entry)).toBe(true);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { usableActionItems } from "../usableActionItems";
|
|
2
|
-
|
|
3
|
-
const action = (identifier: string) =>
|
|
4
|
-
({ identifier, action: { invokeAction: jest.fn() } }) as any;
|
|
5
|
-
|
|
6
|
-
describe("usableActionItems", () => {
|
|
7
|
-
it("keeps a usable list untouched, in order", () => {
|
|
8
|
-
const base = [action("share"), action("favorites")];
|
|
9
|
-
|
|
10
|
-
expect(usableActionItems(base).map((item) => item.identifier)).toEqual([
|
|
11
|
-
"share",
|
|
12
|
-
"favorites",
|
|
13
|
-
]);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("keeps the first of a repeated identifier", () => {
|
|
17
|
-
const firstShare = action("share");
|
|
18
|
-
const secondShare = action("share");
|
|
19
|
-
|
|
20
|
-
const result = usableActionItems([
|
|
21
|
-
firstShare,
|
|
22
|
-
action("favorites"),
|
|
23
|
-
secondShare,
|
|
24
|
-
]);
|
|
25
|
-
|
|
26
|
-
expect(result.map((item) => item.identifier)).toEqual([
|
|
27
|
-
"share",
|
|
28
|
-
"favorites",
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
expect(result[0]).toBe(firstShare);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("drops items that cannot be invoked or have no identifier", () => {
|
|
35
|
-
const result = usableActionItems([
|
|
36
|
-
action("share"),
|
|
37
|
-
{ identifier: "blank" } as any,
|
|
38
|
-
{ identifier: "no-invoke", action: {} } as any,
|
|
39
|
-
{ action: { invokeAction: jest.fn() } } as any,
|
|
40
|
-
action("entry_action_0"),
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
expect(result.map((item) => item.identifier)).toEqual([
|
|
44
|
-
"share",
|
|
45
|
-
"entry_action_0",
|
|
46
|
-
]);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("tolerates a missing list", () => {
|
|
50
|
-
expect(usableActionItems(undefined as any)).toEqual([]);
|
|
51
|
-
});
|
|
52
|
-
});
|