|
1 |
| -import { mount } from '@vue/test-utils' |
| 1 | +import { createApp, h } from 'vue' |
| 2 | +import { resolve } from 'path' |
| 3 | +import { readFileSync } from 'fs' |
| 4 | + |
2 | 5 | import TypeScript from './components/TypeScript.vue'
|
3 | 6 | import Basic from './components/Basic.vue'
|
4 | 7 | import Coffee from './components/Coffee.vue'
|
5 | 8 |
|
| 9 | +function mount(Component, props, slots) { |
| 10 | + document.getElementsByTagName('html')[0].innerHTML = '' |
| 11 | + const el = document.createElement('div') |
| 12 | + el.id = 'app' |
| 13 | + document.body.appendChild(el) |
| 14 | + const Parent = { |
| 15 | + render() { |
| 16 | + return h(Component, props, slots) |
| 17 | + } |
| 18 | + } |
| 19 | + const app = createApp(Parent).mount(el) |
| 20 | +} |
| 21 | + |
6 | 22 | test('processes .vue files', () => {
|
7 |
| - const wrapper = mount(Basic) |
8 |
| - wrapper.vm.toggleClass() |
| 23 | + mount(Basic) |
| 24 | + expect(document.querySelector('h1').textContent).toBe( |
| 25 | + 'Welcome to Your Vue.js App' |
| 26 | + ) |
9 | 27 | })
|
10 | 28 |
|
11 | 29 | test('processes .vue file with lang set to coffee', () => {
|
12 |
| - const wrapper = mount(Coffee) |
13 |
| - expect(wrapper.vm).toBeTruthy() |
| 30 | + mount(Coffee) |
| 31 | + expect(document.querySelector('h1').textContent).toBe('Coffee') |
14 | 32 | })
|
15 | 33 |
|
16 | 34 | test('processes .vue files with lang set to typescript', () => {
|
17 | 35 | const wrapper = mount(TypeScript)
|
18 |
| - expect(wrapper.vm).toBeTruthy() |
| 36 | + expect(document.querySelector('#parent').textContent).toBe('Parent') |
| 37 | + expect(document.querySelector('#child').textContent).toBe('Child') |
19 | 38 | })
|
0 commit comments