Skip to content

Commit 45b545c

Browse files
authored
feat: stub for lightning/platformWorkspaceApi module (#369)
1 parent 0ef561b commit 45b545c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2024, salesforce.com, inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: MIT
5+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6+
*/
7+
import { createTestWireAdapter } from '@salesforce/wire-service-jest-util';
8+
9+
// Mock values that are not part of the lightning/platformWorkspaceApi signature
10+
// In this default test scenario, we assume that two tabs are open, and the first one is focused
11+
export const TAB0 = 'tab0';
12+
export const TAB1 = 'tab1';
13+
export const FOCUSED_TAB_ID = TAB0;
14+
export const ENCLOSING_TAB_ID = TAB0;
15+
export const OPEN_TABS = [{ tabId: TAB0 }, { tabId: TAB1 }];
16+
17+
// Mocked methods and wires that are part of the lightning/platformWorkspaceApi signature
18+
export const closeTab = jest.fn().mockResolvedValue(true);
19+
export const disableTabClose = jest.fn().mockResolvedValue(true);
20+
export const focusTab = jest.fn().mockResolvedValue(true);
21+
export const getAllTabInfo = jest.fn().mockResolvedValue(OPEN_TABS);
22+
export const getFocusedTabInfo = jest.fn().mockResolvedValue({ tabId: TAB0 });
23+
export const getTabInfo = jest.fn().mockResolvedValue({ tabId: TAB0 });
24+
export const openSubtab = jest.fn().mockResolvedValue(true);
25+
export const openTab = jest.fn().mockResolvedValue(true);
26+
export const refreshTab = jest.fn().mockResolvedValue(true);
27+
export const setTabIcon = jest.fn().mockResolvedValue(true);
28+
export const setTabLabel = jest.fn().mockResolvedValue(true);
29+
export const setTabHighlighted = jest.fn().mockResolvedValue(true);
30+
31+
export const EnclosingTabId = createTestWireAdapter(jest.fn());
32+
export const IsConsoleNavigation = createTestWireAdapter(jest.fn());

0 commit comments

Comments
 (0)