Skip to content

Commit b55032a

Browse files
author
sunecosuri
committed
fixed conflict
2 parents 2d772fc + 25f3fb4 commit b55032a

File tree

12 files changed

+70
-25
lines changed

12 files changed

+70
-25
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# vue-test-utils
22

3-
## Currently not published on npm
4-
To use vue-test-utils pre-release:
5-
```
3+
**Currently no published on npm**
4+
5+
To install, use the github URL
6+
7+
```shell
68
npm install --save-dev https://github.com/vuejs/vue-test-utils/
79
```
810

dist/vue-test-utils.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function stubComponents (component, stubs) {
9494
return
9595
}
9696
if (component.components[stub]) {
97-
// Remove cached constructor
97+
// Remove cached constructor
9898
delete component.components[stub]._Ctor;
9999
if (typeof stubs[stub] === 'string') {
100100
component.components[stub] = createStubFromString(stubs[stub], component.components[stub]);
@@ -111,10 +111,7 @@ function stubComponents (component, stubs) {
111111
component.components[stub] = Object.assign({}, stubs[stub]);
112112
}
113113
}
114-
// ignoreElements does not exist in Vue 2.0.x
115-
if (Vue.config.ignoredElements) {
116-
Vue.config.ignoredElements.push(stub);
117-
}
114+
Vue.config.ignoredElements.push(stub);
118115
});
119116
}
120117
}
@@ -765,6 +762,7 @@ Wrapper.prototype.setProps = function setProps (data) {
765762

766763
Object.keys(data).forEach(function (key) {
767764
// $FlowIgnore : Problem with possibly null this.vm
765+
<<<<<<< HEAD
768766
if (this$1.vm._props) {
769767
this$1.vm._props[key] = data[key];
770768
} else {
@@ -775,6 +773,12 @@ Wrapper.prototype.setProps = function setProps (data) {
775773

776774
Object.keys(data).forEach(function (key) {
777775
// $FlowIgnore : Problem with possibly null this.vm
776+
=======
777+
this$1.vm._props[key] = data[key];
778+
});
779+
Object.keys(data).forEach(function (key) {
780+
// $FlowIgnore : Problem with possibly null this.vm
781+
>>>>>>> 25f3fb43b3d5ea9e8d59012077660d946ea46d43
778782
this$1.vm._watchers.forEach(function (watcher) {
779783
if (watcher.expression === key) { watcher.run(); }
780784
});
@@ -1015,7 +1019,11 @@ function mount (component, options) {
10151019
throwError('window is undefined, vue-test-utils needs to be run in a browser environment.\n You can run the tests in node using JSDOM');
10161020
}
10171021

1022+
<<<<<<< HEAD
10181023
var componentToMount = options.clone === false ? component : cloneDeep(component);
1024+
=======
1025+
var componentToMount = options.clone === false ? component : lodash.cloneDeep(component);
1026+
>>>>>>> 25f3fb43b3d5ea9e8d59012077660d946ea46d43
10191027
// Remove cached constructor
10201028
delete componentToMount._Ctor;
10211029

docs/en/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ That was easy as well, so let's step up the game.
9191

9292
### Component data
9393

94-
Changing the data of the component can be quite useful for efficient testing. The method `setData({...})` is meant for changing the data on the instance. You can interact with the instance directly using the `vm` key. As Vue automatically sets all data values and computed properties as getters on the root instance, we can access those values straight away.
94+
Changing the data of the component can be quite useful for efficient testing. The method `setData({...})` is ment for changing the data on the instance. You can interact with the instance directly using the `vm` key. As Vue automatically sets all data values and computed properties as getters on the root instance, we can access those values straight away.
9595
It may be useful to change the data accordingly for a whole group of specs, so `beforeEach()` could be a good place for that:
9696

9797
```js

flow/options.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ declare type Options = { // eslint-disable-line no-undef
66
stubs?: Object,
77
context?: Object,
88
clone?: boolean,
9-
attrs?: Object,
10-
listeners?: Object
9+
children?: Array<Component | string>
1110
}

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
"lint": "eslint --ext js,vue src test flow build --ignore-path .gitignore",
1717
"lint:docs": "eslint --ext js,vue,md docs --ignore-path .gitignore",
1818
"lint:fix": "npm run lint -- --fix",
19-
"setup": "node build/install-hooks.js",
20-
"test": "npm run lint && npm run lint:docs && npm run flow && npm run test:types && npm run test:unit && npm run test:unit:karma",
21-
"test:compatibility": "test/test.sh",
22-
"test:unit": "mocha-webpack --webpack-config build/webpack.test.config.js test/unit/specs --recursive --require test/unit/setup/mocha.setup.js",
23-
"test:unit:karma": "cross-env BABEL_ENV=test TARGET=browser karma start test/unit/setup/karma.conf.js --single-run",
19+
"test": "npm run lint && npm run lint:docs && npm run flow && npm run test:types && npm run test:unit && npm run test:integration && npm run test:integration:karma",
20+
"test:integration": "cross-env BABEL_ENV=test mocha-webpack --webpack-config build/webpack.test.config.js test/integration/specs --recursive --require test/integration/setup/mocha.setup.js",
21+
"test:integration:karma": "cross-env BABEL_ENV=test TARGET=browser karma start test/integration/setup/karma.conf.js --single-run",
22+
"test:unit": "cross-env BABEL_ENV=test mocha-webpack --webpack-config build/webpack.test.config.js test/unit/specs --recursive --require test/unit/setup/mocha.setup.js",
2423
"test:types": "tsc -p types",
2524
"release": "bash build/release.sh",
2625
"release:note": "node build/gen-release-note.js"

src/lib/create-instance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function createConstructor (component: Component, options: Option
2424
const clonedComponent = cloneDeep(component)
2525
component = {
2626
render (h) {
27-
return h(clonedComponent, options.context)
27+
return h(clonedComponent, options.context, options.children)
2828
}
2929
}
3030
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import mount from '~src/mount'
2+
3+
describe('mount.children', () => {
4+
it('mounts functional component with children when passed children array', () => {
5+
const Component = {
6+
functional: true,
7+
render (h, { children }) {
8+
return h('div', children)
9+
},
10+
name: 'common'
11+
}
12+
13+
const context = {}
14+
const children = [
15+
'hello'
16+
]
17+
18+
const wrapper = mount(Component, { context, children })
19+
20+
expect(wrapper.text()).to.contain('hello')
21+
})
22+
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Vue from 'vue'
2+
import mount from '~src/mount'
3+
import Component from '~resources/components/component.vue'
4+
5+
describe('mount.localVue', () => {
6+
it('mounts component using passed localVue as base Vue', () => {
7+
const localVue = Vue.extend()
8+
localVue.version = '2.3'
9+
const wrapper = mount(Component, { localVue: localVue, intercept: { test: true }})
10+
expect(wrapper.vm.test).to.equal(true)
11+
const freshWrapper = mount(Component)
12+
expect(typeof freshWrapper.vm.test).to.equal('undefined')
13+
})
14+
})
15+

test/unit/specs/create-local-vue.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('createLocalVue', () => {
3636
const freshWrapper = mount(Component)
3737
expect(typeof freshWrapper.vm.$route).to.equal('undefined')
3838
})
39+
<<<<<<< HEAD:test/unit/specs/create-local-vue.spec.js
3940

4041
it('installs Router after a previous installed', () => {
4142
const localVue = createLocalVue()
@@ -51,4 +52,6 @@ describe('createLocalVue', () => {
5152
const freshWrapper = mount(Component)
5253
expect(typeof freshWrapper.vm.$route).to.equal('undefined')
5354
})
55+
=======
56+
>>>>>>> 25f3fb43b3d5ea9e8d59012077660d946ea46d43:test/integration/specs/create-local-vue.spec.js
5457
})

test/unit/specs/mount/options/context.spec.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import Vue from 'vue'
22
import mount from '~src/mount'
33

4-
function cannotIdentifyComponent () {
5-
const version = Number(`${Vue.version.split('.')[0]}.${Vue.version.split('.')[1]}`)
6-
return version <= 2.2
7-
}
8-
9-
describe('context', () => {
4+
describe('mount.context', () => {
105
it('mounts functional component when passed context object', () => {
116
if (cannotIdentifyComponent()) {
127
console.log('WARN: no current way to test functional component is component in v2.1.x')

types/index.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ type Stubs = {
2525
[key: string]: Component | string | true
2626
} | string[]
2727

28+
type Children = (Component | string)[]
29+
2830
/**
2931
* Base class of Wrapper and WrapperArray
3032
* It has common methods on both Wrapper and WrapperArray
@@ -87,8 +89,7 @@ interface MountOptions<V extends Vue> extends ComponentOptions<V> {
8789
intercept?: object
8890
slots?: Slots
8991
stubs?: Stubs,
90-
attrs?: object
91-
listeners?: object
92+
children?: Children
9293
}
9394

9495
type ShallowOptions<V extends Vue> = MountOptions<V>

types/test/mount.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ mount(functionalOptions, {
5252
context: {
5353
props: { foo: 'test' }
5454
},
55+
children: ['child', ClassComponent],
5556
stubs: ['child']
5657
})
5758

0 commit comments

Comments
 (0)