-
Notifications
You must be signed in to change notification settings - Fork 159
/
test.js
42 lines (36 loc) · 1.19 KB
/
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
42
import { createApp, h } from 'vue'
import TypeScript from './components/TypeScript.vue'
import Basic from './components/Basic.vue'
import Coffee from './components/Coffee.vue'
import Tsx from './components/Tsx.vue'
function mount(Component, props, slots) {
document.getElementsByTagName('html')[0].innerHTML = ''
const el = document.createElement('div')
el.id = 'app'
document.body.appendChild(el)
const Parent = {
render() {
return h(Component, props, slots)
}
}
createApp(Parent).mount(el)
}
test('processes .vue files', () => {
mount(Basic)
expect(document.querySelector('h1').textContent).toBe(
'Welcome to Your Vue.js App'
)
})
test('processes .vue file with lang set to coffee', () => {
mount(Coffee)
expect(document.querySelector('h1').textContent).toBe('Coffee')
})
test('processes .vue files with lang set to typescript', () => {
mount(TypeScript)
expect(document.querySelector('#parent').textContent).toBe('Parent')
expect(document.querySelector('#child').textContent).toBe('Child')
})
test('processes .vue files with lang set to tsx(typescript)', () => {
mount(Tsx)
expect(document.querySelector('div').textContent).toContain('tsx components')
})