From 40a4b8b2746054b4b9d0eac03cda715a17754a47 Mon Sep 17 00:00:00 2001 From: Jonathan Belcher Date: Mon, 23 Sep 2019 14:17:53 -0400 Subject: [PATCH] Make tests better --- .../checkbox/__snapshots__/test.js.snap | 28 +------------------ lib/components/checkbox/test.js | 20 +++++++++---- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/lib/components/checkbox/__snapshots__/test.js.snap b/lib/components/checkbox/__snapshots__/test.js.snap index 318294abc..53e6c6c10 100644 --- a/lib/components/checkbox/__snapshots__/test.js.snap +++ b/lib/components/checkbox/__snapshots__/test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`renders Checkbox correctly when checked 1`] = ` +exports[`hasn't had its output unintentionally altered 1`] = ` `; - -exports[`renders Checkbox correctly when not checked 1`] = ` - - - -`; diff --git a/lib/components/checkbox/test.js b/lib/components/checkbox/test.js index b8b428c5d..48e0e4456 100644 --- a/lib/components/checkbox/test.js +++ b/lib/components/checkbox/test.js @@ -1,15 +1,25 @@ -import React from 'react'; import Checkbox from './'; +import CheckmarkIcon from '../../icons/checkmark'; +import CircleIcon from '../../icons/circle'; +import React from 'react'; import renderer from 'react-test-renderer'; +import { shallow } from 'enzyme'; -it('renders Checkbox correctly when checked', () => { +it("hasn't had its output unintentionally altered", () => { const tree = renderer.create().toJSON(); expect(tree).toMatchSnapshot(); }); -it('renders Checkbox correctly when not checked', () => { - const tree = renderer.create().toJSON(); - expect(tree).toMatchSnapshot(); +it('renders the circle icon when unchecked', () => { + const checkbox = shallow(); + expect(checkbox.find(CircleIcon)).toHaveLength(1); + expect(checkbox.find(CheckmarkIcon)).toHaveLength(0); +}); + +it('renders the checkmark icon when checked', () => { + const checkbox = shallow(); + expect(checkbox.find(CircleIcon)).toHaveLength(0); + expect(checkbox.find(CheckmarkIcon)).toHaveLength(1); }); it('should call onChange prop when span is clicked', () => {