Skip to content

Commit

Permalink
Add button snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
skaptox committed Nov 30, 2021
1 parent 334c441 commit 9872ff4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ module.exports = {
'^.+\\.vue$': 'vue-jest',
},
testMatch: ['**/*.spec.js'],
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
}
20 changes: 12 additions & 8 deletions src/components/primitives/Button/Button.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { render } from '@testing-library/vue'
import Button from './Button.vue'

let wrapper

describe('Button.vue', () => {
it('renders props.label and type when passed', () => {
const type = 'primary'
const { getByText, container } = render(Button, {
props: { label: type, type: `is-${type}` },
})

getByText(type)
expect(container.firstChild.classList.contains(`is-${type}`)).toBe(true)
beforeEach(() => {
wrapper = render(Button)
})

it('is called', () => {
wrapper.getByRole('button')
})

it('render correctly', () => {
expect(wrapper.html()).toMatchSnapshot()
})
})
2 changes: 1 addition & 1 deletion src/components/primitives/Button/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
props: {
type: {
type: String,
default: 'button'
default: 'is-primary'
},
size: String,
label: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Button.vue render correctly 1`] = `
<button class="button is-primary" type="button">
<!--v-if-->
</button>
`;

0 comments on commit 9872ff4

Please sign in to comment.