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:
parent
61cf4976bb
commit
1328026ea6
@ -21,6 +21,6 @@ Primary.args = {
|
||||
style: 'primary',
|
||||
size: 'small',
|
||||
onClick: () => {
|
||||
alert('Clicked!')
|
||||
console.log('Button pressed!')
|
||||
}
|
||||
}
|
||||
|
@ -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(<Primary onClick={onClickSpy} />)
|
||||
render(<Primary />)
|
||||
const buttonElement = screen.getByRole('button')
|
||||
buttonElement.click()
|
||||
expect(onClickSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('test against args', () => {
|
||||
const onClickSpy = jest.fn()
|
||||
render(<Primary onClick={onClickSpy} />)
|
||||
render(<Primary />)
|
||||
const buttonElement = screen.getByRole('button')
|
||||
// Testing against values coming from the story itself! No need for duplication
|
||||
expect(buttonElement.textContent).toEqual(Primary.args.children)
|
Loading…
Reference in New Issue
Block a user