Skip to content

Commit

Permalink
Adds basic IconButton component tests.
Browse files Browse the repository at this point in the history
Adds basic IconButton component tests. Related to progress on #641.

Testing Instructions
Run npm i && npm run test-unit ensure tests pass. Change Dashicon logic
to ensure tests fail as they should.
  • Loading branch information
BE-Webdesign committed May 30, 2017
1 parent ccf8728 commit 377f3bd
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions components/icon-button/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* External dependencies
*/
import { expect } from 'chai';
import { shallow } from 'enzyme';

/**
* Internal dependencies
*/
import IconButton from '../';

describe( 'IconButton', () => {
describe( 'basic rendering', () => {
it( 'without modifiers', () => {
const iconButton = shallow( <IconButton /> );
expect( iconButton.hasClass( 'components-icon-button' ) ).to.be.true();
expect( iconButton.prop( 'aria-label' ) ).to.be.undefined();
} );

it( 'with icon', () => {
const iconButton = shallow( <IconButton icon="wordpress" /> );
expect( iconButton.find( 'Dashicon' ).shallow().hasClass( 'dashicons-wordpress' ) ).to.be.true();
} );

it( 'with children', () => {
const iconButton = shallow( <IconButton children={ <p className="test">Test</p> } /> );
expect( iconButton.find( '.test' ).shallow().text() ).to.equal( 'Test' );
} );

it( 'with label', () => {
const iconButton = shallow( <IconButton label="WordPress" /> );
expect( iconButton.prop( 'aria-label' ) ).to.equal( 'WordPress' );
} );

it( 'with additonal className', () => {
const iconButton = shallow( <IconButton className="test" /> );
expect( iconButton.hasClass( 'test' ) ).to.be.true();
} );

it( 'with additonal properties', () => {
const iconButton = shallow( <IconButton test="test" /> );
expect( iconButton.node.props.test ).to.equal( 'test' );
} );
} );
} );

0 comments on commit 377f3bd

Please sign in to comment.