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',
|
style: 'primary',
|
||||||
size: 'small',
|
size: 'small',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
alert('Clicked!')
|
console.log('Button pressed!')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
Loading…
x
Reference in New Issue
Block a user