Skip to content

Commit

Permalink
Merge pull request #3780 from hideokamoto/add/test/warning
Browse files Browse the repository at this point in the history
Make component unit test for editor/components/warning/index.js
  • Loading branch information
gziolo authored Dec 4, 2017
2 parents 6b32ec5 + 17ec59d commit 69db55b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions editor/components/warning/test/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Warning should match snapshot 1`] = `
<div
className="editor-warning"
>
<Dashicon
icon="warning"
/>
error
</div>
`;
24 changes: 24 additions & 0 deletions editor/components/warning/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* External dependencies
*/
import { shallow } from 'enzyme';

/**
* Internal dependencies
*/
import Warning from '../index';

describe( 'Warning', () => {
it( 'should match snapshot', () => {
const wrapper = shallow( <Warning>error</Warning> );
expect( wrapper ).toMatchSnapshot();
} );
it( 'should has valid class', () => {
const wrapper = shallow( <Warning /> );
expect( wrapper.hasClass( 'editor-warning' ) ).toBe( true );
} );
it( 'should show child error message element', () => {
const wrapper = shallow( <Warning><p>message</p></Warning> );
expect( wrapper.find( 'p' ).text() ).toBe( 'message' );
} );
} );

0 comments on commit 69db55b

Please sign in to comment.