forked from vuejs/test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTodoApp.spec.js
31 lines (22 loc) · 921 Bytes
/
TodoApp.spec.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
/**
* This is the example app used in the documentation.
* If you want to run it, you will need to build the final bundle with
* yarn build. Then you can run this with `yarn test examples`
*/
import { mount } from '../dist/vue-test-utils.cjs.js'
import TodoApp from './TodoApp.vue'
test('renders a todo', () => {
const wrapper = mount(TodoApp)
expect(wrapper.find('[data-test="todo"]').text()).toBe('Learn Vue.js 3')
})
test('creates a todo', async () => {
const wrapper = mount(TodoApp)
wrapper.find('[data-test="new-todo"]').element.value = 'New todo'
await wrapper.find('[data-test="form"]').trigger('submit')
expect(wrapper.findAll('[data-test="todo"]')).toHaveLength(2)
})
test('completes a todo', async () => {
const wrapper = mount(TodoApp)
await wrapper.find('[data-test="todo-checkbox"]').setChecked()
expect(wrapper.find('[data-test="todo"]').classes()).toContain('completed')
})