forked from vuejs/vue-test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue-wrapper.js
36 lines (33 loc) · 1.07 KB
/
vue-wrapper.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
// @flow
import Wrapper from './wrapper'
import { throwError } from 'shared/util'
import { setWatchersToSync } from './set-watchers-to-sync'
import { orderWatchers } from './order-watchers'
export default class VueWrapper extends Wrapper implements BaseWrapper {
constructor (vm: Component, options: WrapperOptions) {
super(vm._vnode, options)
// $FlowIgnore : issue with defineProperty
Object.defineProperty(this, 'vnode', {
get: () => vm._vnode,
set: () => throwError(`VueWrapper.vnode is read-only`)
})
// $FlowIgnore
Object.defineProperty(this, 'element', {
get: () => vm.$el,
set: () => throwError(`VueWrapper.element is read-only`)
})
// $FlowIgnore
Object.defineProperty(this, 'vm', {
get: () => vm,
set: () => throwError(`VueWrapper.vm is read-only`)
})
if (options.sync) {
setWatchersToSync(vm)
orderWatchers(vm)
}
this.isVm = true
this.isFunctionalComponent = vm.$options._isFunctionalContainer
this._emitted = vm.__emitted
this._emittedByOrder = vm.__emittedByOrder
}
}