-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds basic IconButton component tests.
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
1 parent
ccf8728
commit 377f3bd
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); | ||
} ); | ||
} ); | ||
} ); |