-
Notifications
You must be signed in to change notification settings - Fork 668
/
Copy pathshallow.js
36 lines (32 loc) · 871 Bytes
/
shallow.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 './warn-if-no-window'
import Vue from 'vue'
import mount from './mount'
import type VueWrapper from './vue-wrapper'
import {
createComponentStubsForAll,
createStubs
} from 'shared/stub-components'
import { camelize,
capitalize,
hyphenate
} from 'shared/util'
export default function shallow (
component: Component,
options: Options = {}
): VueWrapper {
const vue = options.localVue || Vue
// remove any recursive components added to the constructor
// in vm._init from previous tests
if (component.name && component.components) {
delete component.components[capitalize(camelize(component.name))]
delete component.components[hyphenate(component.name)]
}
return mount(component, {
...options,
components: {
...createStubs(vue.options.components),
...createComponentStubsForAll(component)
}
})
}