Skip to content

Commit

Permalink
Add custom fixtures for optional control props in order to test the p…
Browse files Browse the repository at this point in the history
…anel header icon toggle in isolation from the other tests.
  • Loading branch information
ramonjd committed Sep 27, 2021
1 parent 854859d commit 2b28194
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/components/src/tools-panel/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,22 @@ describe( 'ToolsPanel', () => {
} );

describe( 'panel header icon toggle', () => {
const optionalControls = {
attributes: { value: false },
hasValue: jest.fn().mockImplementation( () => {
return !! optionalControls.attributes.value;
} ),
label: 'Optional',
onDeselect: jest.fn(),
onSelect: jest.fn(),
isShownByDefault: false,
};

it( 'should render appropriate icons for the dropdown menu', async () => {
render(
<ToolsPanel { ...defaultProps }>
<ToolsPanelItem { ...controlProps }>
<div>Default control</div>
<ToolsPanelItem { ...optionalControls }>
<div>Optional control</div>
</ToolsPanelItem>
</ToolsPanel>
);
Expand All @@ -450,7 +461,7 @@ describe( 'ToolsPanel', () => {

expect( optionsHiddenIcon ).toBeInTheDocument();

await selectMenuItem( controlProps.label );
await selectMenuItem( optionalControls.label );

// There are now NO unactivated, optional menu items in the Tools Panel dropdown.
expect(
Expand Down

0 comments on commit 2b28194

Please sign in to comment.