Skip to content

Commit

Permalink
Also test rendered children of PanelColorSettings in snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Oct 17, 2018
1 parent 42b4476 commit 6719168
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,42 @@ exports[`PanelColorSettings matches the snapshot 1`] = `
/>
`;

exports[`PanelColorSettings matches the snapshot 2`] = `
<PanelBody
className="editor-panel-color-settings"
title={
<span
className="editor-panel-color-settings__panel-title"
>
Test Title
<ColorIndicator
aria-label="(border color: #000)"
colorValue="#000"
/>
<ColorIndicator
aria-label="(background color: #111)"
colorValue="#111"
/>
</span>
}
>
<WithColorContext(IfCondition(ColorPaletteControl))
colors={Array []}
key="0"
label="border color"
onChange={[Function]}
value="#000"
/>
<WithColorContext(IfCondition(ColorPaletteControl))
colors={Array []}
key="1"
label="background color"
onChange={[Function]}
value="#111"
/>
</PanelBody>
`;

exports[`PanelColorSettings should render a color panel if at least one setting specifies some colors to choose 1`] = `
<Component
colorSettings={
Expand Down Expand Up @@ -50,6 +86,52 @@ exports[`PanelColorSettings should render a color panel if at least one setting
/>
`;

exports[`PanelColorSettings should render a color panel if at least one setting specifies some colors to choose 2`] = `
<PanelBody
className="editor-panel-color-settings"
title={
<span
className="editor-panel-color-settings__panel-title"
>
Test Title
<ColorIndicator
aria-label="(border color: #000)"
colorValue="#000"
/>
<ColorIndicator
aria-label="(background color: #111)"
colorValue="#111"
/>
</span>
}
>
<WithColorContext(IfCondition(ColorPaletteControl))
colors={
Array [
Object {
"color": "#ff0000",
"name": "Red",
"slug": "red",
},
]
}
disableCustomColors={true}
key="0"
label="border color"
onChange={[Function]}
value="#000"
/>
<WithColorContext(IfCondition(ColorPaletteControl))
colors={Array []}
disableCustomColors={true}
key="1"
label="background color"
onChange={[Function]}
value="#111"
/>
</PanelBody>
`;

exports[`PanelColorSettings should render a color panel if at least one setting supports custom colors 1`] = `
<Component
colorSettings={
Expand All @@ -72,3 +154,41 @@ exports[`PanelColorSettings should render a color panel if at least one setting
title="Test Title"
/>
`;

exports[`PanelColorSettings should render a color panel if at least one setting supports custom colors 2`] = `
<PanelBody
className="editor-panel-color-settings"
title={
<span
className="editor-panel-color-settings__panel-title"
>
Test Title
<ColorIndicator
aria-label="(border color: #000)"
colorValue="#000"
/>
<ColorIndicator
aria-label="(background color: #111)"
colorValue="#111"
/>
</span>
}
>
<WithColorContext(IfCondition(ColorPaletteControl))
colors={Array []}
disableCustomColors={true}
key="0"
label="border color"
onChange={[Function]}
value="#000"
/>
<WithColorContext(IfCondition(ColorPaletteControl))
colors={Array []}
disableCustomColors={false}
key="1"
label="background color"
onChange={[Function]}
value="#111"
/>
</PanelBody>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe( 'PanelColorSettings', () => {
);

expect( wrapper ).toMatchSnapshot();
expect( wrapper.dive() ).toMatchSnapshot();
} );

it( 'should not render anything if there are no colors to choose', () => {
Expand Down Expand Up @@ -80,6 +81,7 @@ describe( 'PanelColorSettings', () => {
);
expect( wrapper.type() ).not.toBeNull();
expect( wrapper ).toMatchSnapshot();
expect( wrapper.dive() ).toMatchSnapshot();
} );

it( 'should render a color panel if at least one setting specifies some colors to choose', () => {
Expand Down Expand Up @@ -109,6 +111,7 @@ describe( 'PanelColorSettings', () => {
);
expect( wrapper.type() ).not.toBeNull();
expect( wrapper ).toMatchSnapshot();
expect( wrapper.dive() ).toMatchSnapshot();
} );

it( 'should not render anything if none of the setting panels has colors to choose', () => {
Expand Down

0 comments on commit 6719168

Please sign in to comment.