This repository has been archived by the owner on Jun 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Icon): Refactor Icon tests using enzyme
- Loading branch information
Tommy Leunen
committed
Jul 8, 2016
1 parent
41a13a9
commit e9ca4ba
Showing
3 changed files
with
38 additions
and
31 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,32 @@ | ||
/* eslint-env mocha */ | ||
import chai, { expect } from 'chai'; | ||
import chaiEnzyme from 'chai-enzyme'; | ||
import { shallow } from 'enzyme'; | ||
import React from 'react'; | ||
import Icon from '../'; | ||
|
||
chai.use(chaiEnzyme()); | ||
|
||
describe('Icon', () => { | ||
it('should be a <i>', () => { | ||
const wrapper = shallow(<Icon name="add" />); | ||
|
||
expect(wrapper) | ||
.to.have.tagName('i') | ||
.to.have.text('add'); | ||
}); | ||
|
||
it('should have material-icons css class', () => { | ||
const wrapper = shallow(<Icon name="add" />); | ||
|
||
expect(wrapper).to.have.className('material-icons'); | ||
}); | ||
|
||
it('should allow custom css classes', () => { | ||
const wrapper = shallow(<Icon name="mood" className="my-custom-class" />); | ||
|
||
expect(wrapper) | ||
.to.have.className('material-icons') | ||
.to.have.className('my-custom-class'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import React, { PropTypes } from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
const propTypes = { | ||
className: PropTypes.string, | ||
name: PropTypes.string.isRequired | ||
}; | ||
|
||
const Icon = (props) => { | ||
const { className, name, ...otherProps } = props; | ||
const classes = classNames('material-icons', className); | ||
|
||
return <i className={classes} {...otherProps}>{name}</i>; | ||
}; | ||
|
||
Icon.propTypes = { | ||
className: PropTypes.string, | ||
name: PropTypes.string.isRequired | ||
}; | ||
Icon.propTypes = propTypes; | ||
|
||
export default Icon; |
This file was deleted.
Oops, something went wrong.