-
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 rendering dashicon unit tests. Related to #641. The Dashicon should not render when an icon is not provided.
- Loading branch information
1 parent
48ab106
commit 5f72463
Showing
3 changed files
with
41 additions
and
1 deletion.
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,38 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { expect } from 'chai'; | ||
import { shallow } from 'enzyme'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Dashicon from '../'; | ||
|
||
describe( 'Dashicon', () => { | ||
describe( 'basic rendering', () => { | ||
it( 'without properties', () => { | ||
const dashicon = shallow( <Dashicon /> ); | ||
// Unrendered element. | ||
expect( dashicon.type() ).to.be.null(); | ||
} ); | ||
|
||
it( 'with icon property', () => { | ||
const dashicon = shallow( <Dashicon icon="wordpress" /> ); | ||
// OH NO CAPITAL P DANGIT! | ||
expect( dashicon.find( 'title' ).text() ).to.equal( 'Wordpress' ); | ||
expect( dashicon.hasClass( 'dashicon' ) ).to.be.true(); | ||
expect( dashicon.hasClass( 'dashicons-wordpress' ) ).to.be.true(); | ||
expect( dashicon.type() ).to.equal( 'svg' ); | ||
expect( dashicon.prop( 'xmlns' ) ).to.equal( 'http://www.w3.org/2000/svg' ); | ||
expect( dashicon.prop( 'width' ) ).to.equal( '20' ); | ||
expect( dashicon.prop( 'height' ) ).to.equal( '20' ); | ||
expect( dashicon.prop( 'viewBox' ) ).to.equal( '0 0 20 20' ); | ||
} ); | ||
|
||
it( 'with additional class name', () => { | ||
const dashicon = shallow( <Dashicon icon="wordpress" className="capital-p-dangit" /> ); | ||
expect( dashicon.hasClass( 'capital-p-dangit' ) ).to.be.true(); | ||
} ); | ||
} ); | ||
} ); |
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
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