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

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sureshHARDIYA committed Nov 9, 2016
1 parent 630847b commit b4ea11b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Notify/__tests__/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
exports[`Notify should render correctly 1`] = `
<Portal
isOpened={true}
onClose={[Function]}>
<div
className="uk-notify uk-notify-top-center">
<div
className="uk-notify-message uk-notify-message-warning"
style={
Object {
"marginTop": "-64px",
"overflow": "hidden",
"transition": "margin ease-out 300ms",
}
}>
<a
className="uk-close"
onClick={[Function]} />
<div>
<i
className="uk-icon-justify uk-icon-check" />
Notification #1
</div>
</div>
</div>
</Portal>
`;
26 changes: 26 additions & 0 deletions src/Notify/__tests__/index-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import renderer from 'react-test-renderer'

import Notify from '../index'

jest.mock('react-portal', () => 'Portal')

describe('Notify', () => {
const defaultProps = {
notifications: [{ id: 1, type: 'warning', message: 'Notification #1' }],
icon: 'check',
isSticky: false,
position: 'top-center',
}
const component = renderer.create(
<Notify {...defaultProps} />
)
it('should render correctly', () => {
expect(component.toJSON()).toMatchSnapshot()
})

it('should hanlde click correctly', () => {
const instance = component.getInstance()
instance.handleClick()
expect(instance.state.isOpened).toBe(true)
})
})

0 comments on commit b4ea11b

Please sign in to comment.