[web] Add tests for js/components/common/Button.jsx

This commit is contained in:
Matthew Shao 2017-05-11 08:19:10 +08:00
parent cafa094f75
commit f3e5c35b49
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,26 @@
import React from 'react'
import renderer from 'react-test-renderer'
import Button from '../../../components/common/Button'
describe('Button Component', () => {
it('should render correctly', () => {
let button = renderer.create(
<Button className="classname" onClick={() => "onclick"} title="title" icon="icon">
<a>foo</a>
</Button>
),
tree = button.toJSON()
expect(tree).toMatchSnapshot()
})
it('should be able to be disabled', () => {
let button = renderer.create(
<Button className="classname" onClick={() => "onclick"} disabled="true" children="children">
<a>foo</a>
</Button>
),
tree = button.toJSON()
expect(tree).toMatchSnapshot()
})
})

View File

@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Button Component should be able to be disabled 1`] = `
<div
className="classname btn btn-default"
disabled="true"
onClick={false}
title={undefined}
>
<a>
foo
</a>
</div>
`;
exports[`Button Component should render correctly 1`] = `
<div
className="classname btn btn-default"
disabled={undefined}
onClick={[Function]}
title="title"
>
<i
className="fa fa-fw icon"
/>
<a>
foo
</a>
</div>
`;