diff --git a/__tests__/Button.test.tsx b/__tests__/Button.test.tsx index 7c95c2a..725875c 100644 --- a/__tests__/Button.test.tsx +++ b/__tests__/Button.test.tsx @@ -1,13 +1,24 @@ import React from 'react'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import { Button } from '../src'; describe('Button', () => { it('should render primary Button', () => { - const { container } = render(); + const onClick = jest.fn(); + + // TODO: refactor + const { container, getByText } = render( + + ); expect(container).toMatchSnapshot(); + + fireEvent.click(getByText('Label')); + + expect(onClick).toHaveBeenCalled(); }); it('should render secondary Button with destructive style', () => { @@ -21,13 +32,20 @@ describe('Button', () => { }); it('should render disabled tertiary Button', () => { - const { container } = render( - ); expect(container).toMatchSnapshot(); + + fireEvent.click(getByText('Label')); + + expect(onClick).not.toHaveBeenCalled(); }); it('should render Button with custom className', () => { diff --git a/__tests__/Checkbox.test.tsx b/__tests__/Checkbox.test.tsx index 331efab..124d449 100644 --- a/__tests__/Checkbox.test.tsx +++ b/__tests__/Checkbox.test.tsx @@ -1,51 +1,86 @@ import React from 'react'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import { Checkbox } from '../src'; describe('Checkbox', () => { + // TODO: check, uncheck + // TODO onChange + it('should render unchecked Checkbox', () => { - const { container } = render( - + const onClick = jest.fn(); + + const { container, getByText } = render( + Label ); expect(container).toMatchSnapshot(); + + fireEvent.click(getByText('Label')); + + // expect(onClick).not.toHaveBeenCalled(); + expect(onClick).toHaveBeenCalled(); + + // TODO: onClick to have been called + // TODO: not to be checked }); it('should render checked Checkbox', () => { + const onClick = jest.fn(); + const { container } = render( - + Label ); expect(container).toMatchSnapshot(); + + // fireEvent.click(getByText('Label')); + + // expect(onClick).not.toHaveBeenCalled(); + + // TODO: onClick not to have been called + // TODO: to be checked }); it('should render disabled Checkbox', () => { - const { container } = render( + const onClick = jest.fn(); + + const { container, getByText } = render( Label ); expect(container).toMatchSnapshot(); + + fireEvent.click(getByText('Label')); + + expect(onClick).not.toHaveBeenCalled(); }); it('should render Checkbox with custom className values', () => { - const { container } = render( + const onClick = jest.fn(); + + const { container, getByText } = render( Label ); expect(container).toMatchSnapshot(); + + fireEvent.click(getByText('Label')); + + expect(onClick).toHaveBeenCalled(); }); }); diff --git a/__tests__/Disclosure.test.tsx b/__tests__/Disclosure.test.tsx index 1fe7470..6a17765 100644 --- a/__tests__/Disclosure.test.tsx +++ b/__tests__/Disclosure.test.tsx @@ -51,4 +51,7 @@ describe('Disclosure', () => { expect(container).toMatchSnapshot(); }); + + // TODO onClick + // TODO default opened }); diff --git a/__tests__/IconButton.test.tsx b/__tests__/IconButton.test.tsx index 141c247..125fa8a 100644 --- a/__tests__/IconButton.test.tsx +++ b/__tests__/IconButton.test.tsx @@ -30,4 +30,7 @@ describe('IconButton', () => { expect(container).toMatchSnapshot(); }); + + // TODO disabled + // TODO onClick }); diff --git a/__tests__/Input.test.tsx b/__tests__/Input.test.tsx index 6408bfd..d34008b 100644 --- a/__tests__/Input.test.tsx +++ b/__tests__/Input.test.tsx @@ -45,4 +45,7 @@ describe('Input', () => { expect(container).toMatchSnapshot(); }); + + // TODO onChange + // TODO disabled }); diff --git a/__tests__/OnboardingTip.test.tsx b/__tests__/OnboardingTip.test.tsx index 076bad9..7261b7e 100644 --- a/__tests__/OnboardingTip.test.tsx +++ b/__tests__/OnboardingTip.test.tsx @@ -25,6 +25,9 @@ describe('OnboardingTip', () => { ); + // TODO getByText expect(container).toMatchSnapshot(); }); + + // TODO onClose }); diff --git a/__tests__/Radio.test.tsx b/__tests__/Radio.test.tsx index 3813e87..e1d109e 100644 --- a/__tests__/Radio.test.tsx +++ b/__tests__/Radio.test.tsx @@ -5,6 +5,7 @@ import { Radio } from '../src'; describe('Radio', () => { it('should render Radio button', () => { + // TODO onChange const { container } = render( Radio button @@ -25,6 +26,7 @@ describe('Radio', () => { }); it('should render disabled Radio button', () => { + // TODO onChange const { container } = render( { ]; it('should render SelectMenu', () => { + // TODO onSelect + // TODO default selected const { container } = render( { it('should render Switch', () => { + // TODO onChange const { container } = render( - + {}}> Label ); @@ -15,8 +16,9 @@ describe('Switch', () => { }); it('should render checked Switch', () => { + // TODO onChange const { container } = render( - + {}}> Label ); @@ -25,8 +27,9 @@ describe('Switch', () => { }); it('should render disabled Switch', () => { + // TODO onChange const { container } = render( - + {}}> Label ); diff --git a/__tests__/Textarea.test.tsx b/__tests__/Textarea.test.tsx index 946810b..d1fb9df 100644 --- a/__tests__/Textarea.test.tsx +++ b/__tests__/Textarea.test.tsx @@ -5,8 +5,9 @@ import { Textarea } from '../src'; describe('Textarea', () => { it('should render Textarea', () => { + // TODO onChange const { container } = render( - + +`; + exports[`Textarea should render Textarea 1`] = `