-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
80 additions
and
2 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
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,57 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders Checkbox correctly when checked 1`] = ` | ||
<span | ||
aria-checked={false} | ||
className="checkbox" | ||
role="checkbox" | ||
tabIndex="0" | ||
> | ||
<span | ||
aria-hidden="true" | ||
className="checkbox__icon" | ||
> | ||
<svg | ||
className="icon-circle" | ||
height="24px" | ||
viewBox="0 0 24 24" | ||
width="24px" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<g | ||
transform="translate(2 2)" | ||
> | ||
<path | ||
d="m10 0c-5.523 0-10 4.477-10 10s4.477 10 10 10 10-4.477 10-10-4.477-10-10-10zm0 18.5c-4.694 0-8.5-3.806-8.5-8.5s3.806-8.5 8.5-8.5 8.5 3.806 8.5 8.5-3.806 8.5-8.5 8.5z" | ||
/> | ||
</g> | ||
</svg> | ||
</span> | ||
</span> | ||
`; | ||
|
||
exports[`renders Checkbox correctly when not checked 1`] = ` | ||
<span | ||
aria-checked={true} | ||
className="checkbox" | ||
role="checkbox" | ||
tabIndex="0" | ||
> | ||
<span | ||
aria-hidden="true" | ||
className="checkbox__icon" | ||
> | ||
<svg | ||
className="icon-checkmark" | ||
height="24px" | ||
viewBox="0 0 24 24" | ||
width="24px" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M11,17.768l-4.884-4.884l1.768-1.768L11,14.232l8.658-8.658C17.823,3.391,15.075,2,12,2C6.477,2,2,6.477,2,12 s4.477,10,10,10s10-4.477,10-10c0-1.528-0.353-2.971-0.966-4.266L11,17.768z" | ||
/> | ||
</svg> | ||
</span> | ||
</span> | ||
`; |
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
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,20 @@ | ||
import React from 'react'; | ||
import Checkbox from './'; | ||
import renderer from 'react-test-renderer'; | ||
|
||
it('renders Checkbox correctly when checked', () => { | ||
const tree = renderer.create(<Checkbox checked={false}></Checkbox>).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders Checkbox correctly when not checked', () => { | ||
const tree = renderer.create(<Checkbox checked={true}></Checkbox>).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it('should call onChange prop when span is clicked', () => { | ||
const noop = jest.fn(); | ||
const output = renderer.create(<Checkbox onChange={noop}></Checkbox>); | ||
output.root.findByType('span').props.onClick(); | ||
expect(noop).toHaveBeenCalled(); | ||
}); |