1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

change test to .tsx

This commit is contained in:
Enzo Vezzaro 2022-04-25 05:59:35 -04:00
parent 61cf4976bb
commit 1328026ea6
2 changed files with 4 additions and 6 deletions

View File

@ -21,6 +21,6 @@ Primary.args = {
style: 'primary', style: 'primary',
size: 'small', size: 'small',
onClick: () => { onClick: () => {
alert('Clicked!') console.log('Button pressed!')
} }
} }

View File

@ -1,3 +1,4 @@
import React from 'react'
import { render, screen } from '@testing-library/react' import { render, screen } from '@testing-library/react'
import { composeStory } from '@storybook/testing-react' import { composeStory } from '@storybook/testing-react'
import Meta, { Primary as PrimaryStory } from './index.stories' 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) const Primary = composeStory(PrimaryStory, Meta)
test('onclick handler is called', () => { test('onclick handler is called', () => {
const onClickSpy = jest.fn() render(<Primary />)
render(<Primary onClick={onClickSpy} />)
const buttonElement = screen.getByRole('button') const buttonElement = screen.getByRole('button')
buttonElement.click() buttonElement.click()
expect(onClickSpy).toHaveBeenCalled()
}) })
test('test against args', () => { test('test against args', () => {
const onClickSpy = jest.fn() render(<Primary />)
render(<Primary onClick={onClickSpy} />)
const buttonElement = screen.getByRole('button') const buttonElement = screen.getByRole('button')
// Testing against values coming from the story itself! No need for duplication // Testing against values coming from the story itself! No need for duplication
expect(buttonElement.textContent).toEqual(Primary.args.children) expect(buttonElement.textContent).toEqual(Primary.args.children)