From 1328026ea69e2abb27bc41facc75a26acd675b66 Mon Sep 17 00:00:00 2001 From: Enzo Vezzaro Date: Mon, 25 Apr 2022 05:59:35 -0400 Subject: [PATCH] change test to .tsx --- src/components/@shared/atoms/Button/index.stories.tsx | 2 +- .../atoms/Button/{index.test.jsx => index.test.tsx} | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) rename src/components/@shared/atoms/Button/{index.test.jsx => index.test.tsx} (78%) diff --git a/src/components/@shared/atoms/Button/index.stories.tsx b/src/components/@shared/atoms/Button/index.stories.tsx index 428f381a8..f17ff95b5 100644 --- a/src/components/@shared/atoms/Button/index.stories.tsx +++ b/src/components/@shared/atoms/Button/index.stories.tsx @@ -21,6 +21,6 @@ Primary.args = { style: 'primary', size: 'small', onClick: () => { - alert('Clicked!') + console.log('Button pressed!') } } diff --git a/src/components/@shared/atoms/Button/index.test.jsx b/src/components/@shared/atoms/Button/index.test.tsx similarity index 78% rename from src/components/@shared/atoms/Button/index.test.jsx rename to src/components/@shared/atoms/Button/index.test.tsx index 7444f1608..70ebcd337 100644 --- a/src/components/@shared/atoms/Button/index.test.jsx +++ b/src/components/@shared/atoms/Button/index.test.tsx @@ -1,3 +1,4 @@ +import React from 'react' import { render, screen } from '@testing-library/react' import { composeStory } from '@storybook/testing-react' import Meta, { Primary as PrimaryStory } from './index.stories' @@ -6,16 +7,13 @@ import Meta, { Primary as PrimaryStory } from './index.stories' const Primary = composeStory(PrimaryStory, Meta) test('onclick handler is called', () => { - const onClickSpy = jest.fn() - render() + render() const buttonElement = screen.getByRole('button') buttonElement.click() - expect(onClickSpy).toHaveBeenCalled() }) test('test against args', () => { - const onClickSpy = jest.fn() - render() + render() const buttonElement = screen.getByRole('button') // Testing against values coming from the story itself! No need for duplication expect(buttonElement.textContent).toEqual(Primary.args.children)