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 b4ea11b commit dd4fe6d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
},
"jest": {
"coverageReporters": [
"lcov"
"lcov",
"text"
],
"coveragePathIgnorePatterns": [
"<rootDir>/lib/",
Expand Down
3 changes: 2 additions & 1 deletion src/Notify/NotifyMesssage.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default class NotifyMesssage extends Component {
{ marginTop: '-64px' },
{ marginTop: '0px' },
]

if (this.state.isClosed) {
return false
}
Expand All @@ -58,6 +59,6 @@ export default class NotifyMesssage extends Component {
{children}
</div>
</div>
)
)
}
}
26 changes: 26 additions & 0 deletions src/Notify/__tests__/NotifyMessage-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import renderer from 'react-test-renderer'

import NotifyMesssage from '../NotifyMesssage'

describe('NotifyMesssage', () => {
const defaultProps = {
children: 'children',
icon: 'check',
position: 'top-center',
}
const component = renderer.create(
<NotifyMesssage {...defaultProps} />
)
it('should render correctly', () => {
expect(component.toJSON()).toMatchSnapshot()
})

it('should return if state is closed', () => {
const instance = component.getInstance()
instance.handleClose()
expect(instance.state.isOpen).toBe(false)

instance.openNotification()
expect(instance.state.isOpen).toBe(true)
})
})
20 changes: 20 additions & 0 deletions src/Notify/__tests__/__snapshots__/NotifyMessage-test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
exports[`NotifyMesssage should render correctly 1`] = `
<div
className="uk-notify-message"
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" />
children
</div>
</div>
`;

0 comments on commit dd4fe6d

Please sign in to comment.