Skip to content

Commit

Permalink
Add tests and clean up css
Browse files Browse the repository at this point in the history
  • Loading branch information
belcherj committed Sep 23, 2019
1 parent 0549faa commit 32e0b00
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Future Release

- Updated Log in and Sign up form to match current styling
- Added tests to Checkbox component

## [v1.7.0](https://github.com/Automattic/simplenote-electron/releases/tag/v1.7.0) (2019-08-12)

Expand Down
57 changes: 57 additions & 0 deletions lib/components/checkbox/__snapshots__/test.js.snap
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>
`;
4 changes: 2 additions & 2 deletions lib/components/checkbox/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
.checkbox__icon {
display: inline;
position: relative;
top: -.09em;
top: -0.09em;

svg {
width: 1.3em;
height: 1.3em;
width: 1.3em;
}
}
20 changes: 20 additions & 0 deletions lib/components/checkbox/test.js
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();
});

0 comments on commit 32e0b00

Please sign in to comment.