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