Skip to content

Commit

Permalink
doc: extra comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pozil committed May 23, 2024
1 parent 0d78a91 commit e6e02b3
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('c-workspace-api', () => {
IsConsoleNavigation.emit(true);
await flushPromises();

// Click button
// Find and click button
const buttonEl = element.shadowRoot.querySelector('lightning-button');
buttonEl.click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ describe('c-workspace-api-close-tab', () => {
});
document.body.appendChild(element);

// Simulate console navigation
IsConsoleNavigation.emit(true);

// Query lightning-button component element
// Find and click button
const buttonEl = element.shadowRoot.querySelector('lightning-button');
buttonEl.click();

// Wait for async event
await flushPromises();

// Check that related platformWorkspaceApi functions have been called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ describe('c-workspace-api-disable-tab-close', () => {
});
document.body.appendChild(element);

// Simulate console navigation
IsConsoleNavigation.emit(true);
await flushPromises();

// Query lightning-input component element
// Find and toggle input
const inputEl = element.shadowRoot.querySelector('lightning-input');
const toggleValue = true;
inputEl.dispatchEvent(
new CustomEvent('change', { detail: { checked: toggleValue } })
);

// Wait for async event
await flushPromises();

// Check that related platformWorkspaceApi functions have been called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ describe('c-workspace-api-focus-tab', () => {
});
document.body.appendChild(element);

// Simulate console navigation
IsConsoleNavigation.emit(true);

// Query lightning-button component element
// Find and click button
const buttonEl = element.shadowRoot.querySelector('lightning-button');
buttonEl.click();

// Wait for async event
await flushPromises();

// Check that related platformWorkspaceApi functions have been called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ describe('c-workspace-api-highlight-tab', () => {
});
document.body.appendChild(element);

// Simulate console navigation
IsConsoleNavigation.emit(true);

// Query lightning-input component element
// Find and toggle input
const inputEl = element.shadowRoot.querySelector('lightning-input');
inputEl.dispatchEvent(
new CustomEvent('change', { detail: { checked: true } })
);

// Wait for async event
await flushPromises();

// Check that related platformWorkspaceApi functions have been called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ describe('c-workspace-api-open-subtab', () => {
});
document.body.appendChild(element);

// Simulate console navigation
IsConsoleNavigation.emit(true);
EnclosingTabId.emit(ENCLOSING_TAB_ID);

// Query lightning-button component element
// Find and click button
const buttonEl = element.shadowRoot.querySelector('lightning-button');
buttonEl.click();

// Wait for async event
await flushPromises();

// Check that related platformWorkspaceApi functions have been called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ describe('c-workspace-api-open-tab', () => {
});
document.body.appendChild(element);

// Simulate console navigation
IsConsoleNavigation.emit(true);
await flushPromises();

// Query lightning-button component element
// Find and click button
const buttonEl = element.shadowRoot.querySelector('lightning-button');
buttonEl.click();

await flushPromises();

// Check that related platformWorkspaceApi functions have been called
expect(openTab).toHaveBeenCalledWith({
pageReference: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ describe('c-workspace-api-refresh-tab', () => {
// Simulate console navigation
IsConsoleNavigation.emit(true);

// Query lightning-button component element
// Find and click button
const buttonEl = element.shadowRoot.querySelector('lightning-button');
buttonEl.click();

// Wait for async event
await flushPromises();

// Check that related platformWorkspaceApi functions have been called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
FOCUSED_TAB_ID
} from 'lightning/platformWorkspaceApi';

const UPDATED_TAB_ICON = 'utility:animal_and_nature';
const UPDATED_TAB_ICON_ALT_TEXT = 'Animal and Nature';

describe('c-workspace-api-set-tab-icon', () => {
afterEach(() => {
// The jsdom instance is shared across test cases in a single file so reset the DOM
Expand All @@ -28,21 +31,25 @@ describe('c-workspace-api-set-tab-icon', () => {
});
document.body.appendChild(element);

const TAB_ICON = 'utility:animal_and_nature';
const TAB_ICON_ALT_TEXT = 'Animal and Nature';
// Simulate console navigation
IsConsoleNavigation.emit(true);

// Query lightning-button component element
// Find and click button
const buttonEl = element.shadowRoot.querySelector('lightning-button');
buttonEl.click();

// Wait for async event
await flushPromises();

// Check that related platformWorkspaceApi functions have been called
expect(getFocusedTabInfo).toHaveBeenCalled();
expect(setTabIcon).toHaveBeenCalledWith(FOCUSED_TAB_ID, TAB_ICON, {
iconAlt: TAB_ICON_ALT_TEXT
});
expect(setTabIcon).toHaveBeenCalledWith(
FOCUSED_TAB_ID,
UPDATED_TAB_ICON,
{
iconAlt: UPDATED_TAB_ICON_ALT_TEXT
}
);
});

it('is accessible', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
FOCUSED_TAB_ID
} from 'lightning/platformWorkspaceApi';

const UPDATED_TAB_LABEL = 'Awesome Label';

describe('c-workspace-api-set-tab-label', () => {
afterEach(() => {
// The jsdom instance is shared across test cases in a single file so reset the DOM
Expand All @@ -28,18 +30,22 @@ describe('c-workspace-api-set-tab-label', () => {
});
document.body.appendChild(element);

const TAB_LABEL = 'Awesome Label';
// Simulate console navigation
IsConsoleNavigation.emit(true);

// Query lightning-button component element
// Find and click button
const buttonEl = element.shadowRoot.querySelector('lightning-button');
buttonEl.click();

// Wait for async event
await flushPromises();

// Check that related platformWorkspaceApi functions have been called
expect(getFocusedTabInfo).toHaveBeenCalled();
expect(setTabLabel).toHaveBeenCalledWith(FOCUSED_TAB_ID, TAB_LABEL);
expect(setTabLabel).toHaveBeenCalledWith(
FOCUSED_TAB_ID,
UPDATED_TAB_LABEL
);
});

it('is accessible', async () => {
Expand Down

0 comments on commit e6e02b3

Please sign in to comment.