Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Commit

Permalink
update Icon tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sureshHARDIYA committed Mar 27, 2017
1 parent 8e5ec35 commit c98e681
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const iconNames = Object.keys(icons)
export default class Icon extends Component {

static propTypes = {
icon: PropTypes.oneOf(iconNames).isRequired,
icon: PropTypes.oneOf(iconNames.concat(['spinner'])).isRequired,
ratio: PropTypes.number.isRequired,
// @TODO custom viewBox validator
viewBox: PropTypes.string.isRequired,
Expand Down
8 changes: 7 additions & 1 deletion src/__tests__/Icon-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import renderer from 'react-test-renderer'
import Icon from '../Icon'

jest.mock('../Spinner', () => 'Spinner')

it('should render correctly', () => {
expect(renderer.create(
<Icon icon="check" load={jest.fn()} ratio={2} />
<Icon icon="check" ratio={2} />
).toJSON()).toMatchSnapshot()

expect(renderer.create(
<Icon icon="spinner" />
).toJSON()).toMatchSnapshot()
})
10 changes: 10 additions & 0 deletions src/__tests__/Spinner-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import renderer from 'react-test-renderer'
import Spinner from '../Spinner'

jest.mock('react-dom')

it('should render correctly', () => {
const component = renderer.create(<Spinner />)
console.log(component)
expect(component.toJSON()).toMatchSnapshot()
})
7 changes: 6 additions & 1 deletion src/__tests__/__snapshots__/Icon-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ exports[`should render correctly 1`] = `
}
}
height={40}
load={[Function]}
viewBox="0 0 20 20"
width={40}
xmlns="http://www.w3.org/2000/svg"
/>
</span>
`;

exports[`should render correctly 2`] = `
<Spinner
className=""
/>
`;

0 comments on commit c98e681

Please sign in to comment.