Skip to content

Commit 9872ff4

Browse files
committed
Add button snapshot
1 parent 334c441 commit 9872ff4

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ module.exports = {
66
'^.+\\.vue$': 'vue-jest',
77
},
88
testMatch: ['**/*.spec.js'],
9+
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
910
}
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { render } from '@testing-library/vue'
22
import Button from './Button.vue'
33

4+
let wrapper
5+
46
describe('Button.vue', () => {
5-
it('renders props.label and type when passed', () => {
6-
const type = 'primary'
7-
const { getByText, container } = render(Button, {
8-
props: { label: type, type: `is-${type}` },
9-
})
10-
11-
getByText(type)
12-
expect(container.firstChild.classList.contains(`is-${type}`)).toBe(true)
7+
beforeEach(() => {
8+
wrapper = render(Button)
9+
})
10+
11+
it('is called', () => {
12+
wrapper.getByRole('button')
13+
})
14+
15+
it('render correctly', () => {
16+
expect(wrapper.html()).toMatchSnapshot()
1317
})
1418
})

src/components/primitives/Button/Button.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
props: {
77
type: {
88
type: String,
9-
default: 'button'
9+
default: 'is-primary'
1010
},
1111
size: String,
1212
label: String,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Button.vue render correctly 1`] = `
4+
<button class="button is-primary" type="button">
5+
<!--v-if-->
6+
</button>
7+
`;

0 commit comments

Comments
 (0)