Skip to content

Commit 8549590

Browse files
committed
refactor: tests
1 parent 2a43675 commit 8549590

File tree

1 file changed

+25
-6
lines changed
  • e2e/__projects__/babel-in-package

1 file changed

+25
-6
lines changed
Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
1-
import { mount } from '@vue/test-utils'
1+
import { createApp, h } from 'vue'
2+
import { resolve } from 'path'
3+
import { readFileSync } from 'fs'
4+
25
import TypeScript from './components/TypeScript.vue'
36
import Basic from './components/Basic.vue'
47
import Coffee from './components/Coffee.vue'
58

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+
622
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+
)
927
})
1028

1129
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')
1432
})
1533

1634
test('processes .vue files with lang set to typescript', () => {
1735
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')
1938
})

0 commit comments

Comments
 (0)