-
Notifications
You must be signed in to change notification settings - Fork 88
/
vue.test.js
41 lines (36 loc) · 892 Bytes
/
vue.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import Vue from 'vue/dist/vue'
import '@testing-library/jest-dom/extend-expect'
import {userEventAsync} from './user-event-async'
import {getQueriesForElement} from '@testing-library/dom'
Vue.config.productionTip = false
Vue.config.devtools = false
const Counter = {
template: `
<div>
<button @click='increment'>
{{count}}
</button>
</div>
`,
data: () => ({count: 0}),
methods: {
increment() {
this.count++
},
},
}
function render(Component) {
const vm = new Vue(Component).$mount()
return {
container: vm.$el,
...getQueriesForElement(vm.$el),
}
}
test('counter increments', async () => {
const {getByText} = render(Counter)
const counter = getByText('0')
await userEventAsync.click(counter)
expect(counter).toHaveTextContent('1')
await userEventAsync.click(counter)
expect(counter).toHaveTextContent('2')
})