Skip to content

Commit

Permalink
Add revisions.
Browse files Browse the repository at this point in the history
Adding revisions to the tests.  Cleaning up Enzyme API usage, and
breaking larger tests into more test cases.  Spelling corrections added.
  • Loading branch information
BE-Webdesign committed Jun 1, 2017
1 parent ca9e7e1 commit c56aa87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions components/button/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ describe( 'Button', () => {
} );

it( 'should render and additional WordPress prop of value awesome', () => {
const button = <Button WordPress="awesome" />;
const button = shallow( <Button WordPress="awesome" /> );

expect( button.props.WordPress ).to.equal( 'awesome' );
expect( button.prop( 'WordPress' ) ).to.equal( 'awesome' );
} );
} );

Expand Down
14 changes: 8 additions & 6 deletions components/form-toggle/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe( 'FormToggle', () => {
expect( formToggle.find( '.components-form-toggle__hint' ).text() ).to.equal( 'On' );
} );

it( 'shouuld render with an additional className', () => {
it( 'should render with an additional className', () => {
const formToggle = shallow( <FormToggle className="testing" /> );
expect( formToggle.hasClass( 'testing' ) ).to.be.true();
} );
Expand All @@ -39,14 +39,16 @@ describe( 'FormToggle', () => {
expect( formToggle.find( '.components-form-toggle__input' ).prop( 'id' ) ).to.equal( 'test' );
} );

it( 'should render a checkbox with a noop on change and if an onChange function is provided override the noop', () => {
let formToggle = shallow( <FormToggle /> );
let checkBox = formToggle.prop( 'children' ).find( child => 'input' === child.type && 'checkbox' === child.props.type );
it( 'should render a checkbox with a noop onChange', () => {
const formToggle = shallow( <FormToggle /> );
const checkBox = formToggle.prop( 'children' ).find( child => 'input' === child.type && 'checkbox' === child.props.type );
expect( checkBox.props.onChange ).to.equal( noop );
} );

it( 'should render a checkbox with a user-provided onChange', () => {
const testFunction = ( event ) => event;
formToggle = shallow( <FormToggle onChange={ testFunction } /> );
checkBox = formToggle.prop( 'children' ).find( child => 'input' === child.type && 'checkbox' === child.props.type );
const formToggle = shallow( <FormToggle onChange={ testFunction } /> );
const checkBox = formToggle.prop( 'children' ).find( child => 'input' === child.type && 'checkbox' === child.props.type );
expect( checkBox.props.onChange ).to.equal( testFunction );
} );

Expand Down

0 comments on commit c56aa87

Please sign in to comment.