From 69971d659dc04d5d2f8a32fe3d317c834bd41c5d Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Fri, 27 Jul 2018 15:37:45 +0800 Subject: [PATCH] Add tests for ColorPaletteControl and export HOC'ed version as default --- editor/components/color-palette/control.js | 6 ++--- .../test/__snapshots__/control.js.snap | 22 ++++++++++++++++ .../components/color-palette/test/control.js | 25 +++++++++++++++++++ .../test/__snapshots__/index.js.snap | 4 +-- 4 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 editor/components/color-palette/test/__snapshots__/control.js.snap create mode 100644 editor/components/color-palette/test/control.js diff --git a/editor/components/color-palette/control.js b/editor/components/color-palette/control.js index 5863a5f9e605f..a7755eec4d25e 100644 --- a/editor/components/color-palette/control.js +++ b/editor/components/color-palette/control.js @@ -16,7 +16,7 @@ import { getColorName } from '../colors'; // translators: first %s: The type of color (e.g. background color), second %s: the color name or value (e.g. red or #ff0000) const colorIndicatorAriaLabel = __( '(current %s: %s)' ); -const ColorPaletteControl = withColorContext( ( { label, value, onChange, colors } ) => { +export function ColorPaletteControl( { label, value, onChange, colors } ) { const colorName = getColorName( colors, value ); const ariaLabel = sprintf( colorIndicatorAriaLabel, label.toLowerCase(), colorName || value ); @@ -43,6 +43,6 @@ const ColorPaletteControl = withColorContext( ( { label, value, onChange, colors /> ); -} ); +} -export default ColorPaletteControl; +export default withColorContext( ColorPaletteControl ); diff --git a/editor/components/color-palette/test/__snapshots__/control.js.snap b/editor/components/color-palette/test/__snapshots__/control.js.snap new file mode 100644 index 0000000000000..0dc3d02690413 --- /dev/null +++ b/editor/components/color-palette/test/__snapshots__/control.js.snap @@ -0,0 +1,22 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ColorPaletteControl matches the snapshot 1`] = ` + + Test Color + + + } +> + + +`; diff --git a/editor/components/color-palette/test/control.js b/editor/components/color-palette/test/control.js new file mode 100644 index 0000000000000..9d43713fb48e7 --- /dev/null +++ b/editor/components/color-palette/test/control.js @@ -0,0 +1,25 @@ +/** + * External dependencies + */ +import { shallow } from 'enzyme'; +import { noop } from 'lodash'; + +/** + * Internal dependencies + */ +import { ColorPaletteControl } from '../control'; + +describe( 'ColorPaletteControl', () => { + it( 'matches the snapshot', () => { + const wrapper = shallow( + + ); + + expect( wrapper ).toMatchSnapshot(); + } ); +} ); diff --git a/editor/components/panel-color-settings/test/__snapshots__/index.js.snap b/editor/components/panel-color-settings/test/__snapshots__/index.js.snap index 06183b8c884ad..e1050e34708c3 100644 --- a/editor/components/panel-color-settings/test/__snapshots__/index.js.snap +++ b/editor/components/panel-color-settings/test/__snapshots__/index.js.snap @@ -19,13 +19,13 @@ exports[`PanelColorSettings matches the snapshot 1`] = ` } > - -