fixed snapshot tests
This commit is contained in:
@@ -4,6 +4,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react'
|
||||
import Button from '../Button'
|
||||
import { ButtonType } from '../Button'
|
||||
import PlayLogo from '../../../static/images/play-button.svg'
|
||||
import AddLogo from '../../../static/images/add.svg'
|
||||
|
||||
export default {
|
||||
title: 'Button',
|
||||
@@ -29,7 +30,6 @@ export default {
|
||||
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />
|
||||
|
||||
export const Primary = Template.bind({})
|
||||
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
||||
Primary.args = {
|
||||
label: 'Primary',
|
||||
buttonType: ButtonType.Primary,
|
||||
@@ -41,9 +41,16 @@ Secondary.args = {
|
||||
buttonType: ButtonType.Secondary,
|
||||
}
|
||||
|
||||
export const WithIcon = Template.bind({})
|
||||
WithIcon.args = {
|
||||
label: 'Icon Btn',
|
||||
export const PrimaryWithIcon = Template.bind({})
|
||||
PrimaryWithIcon.args = {
|
||||
label: 'Primary Ic',
|
||||
buttonType: ButtonType.Primary,
|
||||
Icon: <PlayLogo />,
|
||||
}
|
||||
|
||||
export const SecondaryWithIcon = Template.bind({})
|
||||
SecondaryWithIcon.args = {
|
||||
label: 'Secondary Ic',
|
||||
buttonType: ButtonType.Secondary,
|
||||
Icon: <AddLogo />,
|
||||
}
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
import { Primary } from './Button.stories'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import { Primary, Secondary } from './Button.stories'
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
describe('button', (): void => {
|
||||
describe('Button', (): void => {
|
||||
test('should render primary button', (): void => {
|
||||
const { container } = render(<Primary {...Primary.args} />)
|
||||
expect(container).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should render secondary button', (): void => {
|
||||
const { container } = render(<Secondary {...Secondary.args} />)
|
||||
expect(container).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should render primary button with icon', (): void => {
|
||||
const { container } = render(<Secondary {...Secondary.args} />)
|
||||
expect(container).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`button should render primary button 1`] = `
|
||||
exports[`Button should render primary button 1`] = `
|
||||
<div>
|
||||
<button
|
||||
class="n-button Primary"
|
||||
@@ -9,3 +9,13 @@ exports[`button should render primary button 1`] = `
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Button should render secondary button 1`] = `
|
||||
<div>
|
||||
<button
|
||||
class="n-button Secondary"
|
||||
>
|
||||
Secondary
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user