From 32e0b007acf9c85b8f1089ba5403dc59cd80cd08 Mon Sep 17 00:00:00 2001 From: Jonathan Belcher Date: Mon, 23 Sep 2019 11:49:23 -0400 Subject: [PATCH] Add tests and clean up css --- CHANGELOG.md | 1 + .../checkbox/__snapshots__/test.js.snap | 57 +++++++++++++++++++ lib/components/checkbox/style.scss | 4 +- lib/components/checkbox/test.js | 20 +++++++ 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 lib/components/checkbox/__snapshots__/test.js.snap create mode 100644 lib/components/checkbox/test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index e2da87d11..0c3cc8c03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/components/checkbox/__snapshots__/test.js.snap b/lib/components/checkbox/__snapshots__/test.js.snap new file mode 100644 index 000000000..318294abc --- /dev/null +++ b/lib/components/checkbox/__snapshots__/test.js.snap @@ -0,0 +1,57 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders Checkbox correctly when checked 1`] = ` + + + +`; + +exports[`renders Checkbox correctly when not checked 1`] = ` + + + +`; diff --git a/lib/components/checkbox/style.scss b/lib/components/checkbox/style.scss index 5ef636149..99456b543 100644 --- a/lib/components/checkbox/style.scss +++ b/lib/components/checkbox/style.scss @@ -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; } } diff --git a/lib/components/checkbox/test.js b/lib/components/checkbox/test.js new file mode 100644 index 000000000..b8b428c5d --- /dev/null +++ b/lib/components/checkbox/test.js @@ -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().toJSON(); + expect(tree).toMatchSnapshot(); +}); + +it('renders Checkbox correctly when not checked', () => { + const tree = renderer.create().toJSON(); + expect(tree).toMatchSnapshot(); +}); + +it('should call onChange prop when span is clicked', () => { + const noop = jest.fn(); + const output = renderer.create(); + output.root.findByType('span').props.onClick(); + expect(noop).toHaveBeenCalled(); +});