/
createApp.spec.ts
38 lines (32 loc) 路 987 Bytes
/
createApp.spec.ts
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
import { createApp, h } from '../src'
describe('createApp for dom', () => {
// #2926
test('mount to SVG container', () => {
const root = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
createApp({
render() {
return h('g')
}
}).mount(root)
expect(root.children.length).toBe(1)
expect(root.children[0] instanceof SVGElement).toBe(true)
})
// #4398
test('should not mutate original Root options object', () => {
const originalObj = {
data() {
return {
counter: 0
}
}
}
const handler = jest.fn((msg, instance, trace) => {
expect(msg).toMatch(`Component is missing template or render function`)
})
const Root = { ...originalObj}
const app = createApp(Root)
app.config.warnHandler = handler
app.mount(document.createElement('div'))
expect(originalObj).toMatchObject(Root) // ensure no additional properties are added to Root
})
})