From 2b28194dd0c9d23b499b1380630fe841309f2184 Mon Sep 17 00:00:00 2001 From: ramonjd Date: Mon, 27 Sep 2021 11:38:55 +1000 Subject: [PATCH] Add custom fixtures for optional control props in order to test the panel header icon toggle in isolation from the other tests. --- .../components/src/tools-panel/test/index.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/components/src/tools-panel/test/index.js b/packages/components/src/tools-panel/test/index.js index 90496342fddeb8..f77b09a29b2b8b 100644 --- a/packages/components/src/tools-panel/test/index.js +++ b/packages/components/src/tools-panel/test/index.js @@ -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( - -
Default control
+ +
Optional control
); @@ -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(