Skip to content

Commit 38efad1

Browse files
committed
build: 1.0.0-beta.10
1 parent ea36c68 commit 38efad1

File tree

4 files changed

+1510
-1919
lines changed

4 files changed

+1510
-1919
lines changed

dist/vue-test-utils.iife.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ function createComponentStubsForAll (component) {
131131
Object.keys(component.components).forEach(function (c) {
132132
// Remove cached constructor
133133
delete component.components[c]._Ctor;
134+
if (!component.components[c].name) {
135+
component.components[c].name = c;
136+
}
134137
components[c] = createBlankStub(component.components[c]);
135138

136139
// ignoreElements does not exist in Vue 2.0.x
@@ -245,6 +248,8 @@ var NAME_SELECTOR = 'NAME_SELECTOR';
245248
var COMPONENT_SELECTOR = 'COMPONENT_SELECTOR';
246249
var REF_SELECTOR = 'REF_SELECTOR';
247250
var DOM_SELECTOR = 'DOM_SELECTOR';
251+
var VUE_VERSION = Number(((Vue.version.split('.')[0]) + "." + (Vue.version.split('.')[1])));
252+
var FUNCTIONAL_OPTIONS = VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
248253

249254
//
250255

@@ -313,7 +318,7 @@ function findAllFunctionalComponentsFromVnode (
313318
) {
314319
if ( components === void 0 ) components = [];
315320

316-
if (vnode.fnOptions) {
321+
if (vnode[FUNCTIONAL_OPTIONS] || vnode.functionalContext) {
317322
components.push(vnode);
318323
}
319324
if (vnode.children) {
@@ -339,11 +344,15 @@ function vmCtorMatchesSelector (component, selector) {
339344
}
340345

341346
function vmFunctionalCtorMatchesSelector (component, Ctor) {
342-
if (!component.fnOptions) {
347+
if (VUE_VERSION < 2.3) {
348+
throwError('find for functional components is not support in Vue < 2.3');
349+
}
350+
351+
if (!component[FUNCTIONAL_OPTIONS]) {
343352
return false
344353
}
345-
var Ctors = Object.keys(component.fnOptions._Ctor);
346-
return Ctors.some(function (c) { return Ctor[c] === component.fnOptions._Ctor[c]; })
354+
var Ctors = Object.keys(component[FUNCTIONAL_OPTIONS]._Ctor);
355+
return Ctors.some(function (c) { return Ctor[c] === component[FUNCTIONAL_OPTIONS]._Ctor[c]; })
347356
}
348357

349358
function findVueComponents (
@@ -352,10 +361,10 @@ function findVueComponents (
352361
selector
353362
) {
354363
if (selector.functional) {
355-
var components$1 = root._vnode
364+
var nodes = root._vnode
356365
? findAllFunctionalComponentsFromVnode(root._vnode)
357366
: findAllFunctionalComponentsFromVnode(root);
358-
return components$1.filter(function (component) { return vmFunctionalCtorMatchesSelector(component, selector._Ctor); })
367+
return nodes.filter(function (node) { return vmFunctionalCtorMatchesSelector(node, selector._Ctor); })
359368
}
360369
var components = root._isVue
361370
? findAllVueComponentsFromVm(root)
@@ -930,6 +939,8 @@ Wrapper.prototype.hasProp = function hasProp (prop, value) {
930939
* Checks if wrapper has a style with value
931940
*/
932941
Wrapper.prototype.hasStyle = function hasStyle (style, value) {
942+
warn('hasStyle() has been deprecated and will be removed in version 1.0.0. Use wrapper.element.style instead');
943+
933944
if (typeof style !== 'string') {
934945
throwError('wrapper.hasStyle() must be passed style as a string');
935946
}
@@ -3881,12 +3892,12 @@ function update () {
38813892
if (this.$_mountingOptionsSlots) {
38823893
addSlots(this, this.$_mountingOptionsSlots);
38833894
}
3884-
var vnodes = this._render();
3885-
this._update(vnodes);
3886-
this.$children.forEach(function (child) { return update.call(child); });
38873895
this._watchers.forEach(function (watcher) {
38883896
watcher.run();
38893897
});
3898+
var vnodes = this._render();
3899+
this._update(vnodes);
3900+
this.$children.forEach(function (child) { return update.call(child); });
38903901
}
38913902

38923903
var VueWrapper = (function (Wrapper$$1) {
@@ -3919,7 +3930,11 @@ var VueWrapper = (function (Wrapper$$1) {
39193930
//
39203931
function addMocks (mockedProperties, Vue$$1) {
39213932
Object.keys(mockedProperties).forEach(function (key) {
3922-
Vue$$1.prototype[key] = mockedProperties[key];
3933+
try {
3934+
Vue$$1.prototype[key] = mockedProperties[key];
3935+
} catch (e) {
3936+
warn('could not overwrite property $store, this usually caused by a plugin that has added the property as a read-only value');
3937+
}
39233938
Vue.util.defineReactive(Vue$$1, key, mockedProperties[key]);
39243939
});
39253940
}
@@ -3985,6 +4000,14 @@ function addEventLogger (vue) {
39854000
//
39864001

39874002
function compileTemplate (component) {
4003+
if (component.components) {
4004+
Object.keys(component.components).forEach(function (c) {
4005+
var cmp = component.components[c];
4006+
if (!cmp.render) {
4007+
compileTemplate(cmp);
4008+
}
4009+
});
4010+
}
39884011
if (component.extends) {
39894012
compileTemplate(component.extends);
39904013
}

dist/vue-test-utils.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ function createComponentStubsForAll (component) {
133133
Object.keys(component.components).forEach(function (c) {
134134
// Remove cached constructor
135135
delete component.components[c]._Ctor;
136+
if (!component.components[c].name) {
137+
component.components[c].name = c;
138+
}
136139
components[c] = createBlankStub(component.components[c]);
137140

138141
// ignoreElements does not exist in Vue 2.0.x
@@ -247,6 +250,8 @@ var NAME_SELECTOR = 'NAME_SELECTOR';
247250
var COMPONENT_SELECTOR = 'COMPONENT_SELECTOR';
248251
var REF_SELECTOR = 'REF_SELECTOR';
249252
var DOM_SELECTOR = 'DOM_SELECTOR';
253+
var VUE_VERSION = Number(((Vue.version.split('.')[0]) + "." + (Vue.version.split('.')[1])));
254+
var FUNCTIONAL_OPTIONS = VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
250255

251256
//
252257

@@ -315,7 +320,7 @@ function findAllFunctionalComponentsFromVnode (
315320
) {
316321
if ( components === void 0 ) components = [];
317322

318-
if (vnode.fnOptions) {
323+
if (vnode[FUNCTIONAL_OPTIONS] || vnode.functionalContext) {
319324
components.push(vnode);
320325
}
321326
if (vnode.children) {
@@ -341,11 +346,15 @@ function vmCtorMatchesSelector (component, selector) {
341346
}
342347

343348
function vmFunctionalCtorMatchesSelector (component, Ctor) {
344-
if (!component.fnOptions) {
349+
if (VUE_VERSION < 2.3) {
350+
throwError('find for functional components is not support in Vue < 2.3');
351+
}
352+
353+
if (!component[FUNCTIONAL_OPTIONS]) {
345354
return false
346355
}
347-
var Ctors = Object.keys(component.fnOptions._Ctor);
348-
return Ctors.some(function (c) { return Ctor[c] === component.fnOptions._Ctor[c]; })
356+
var Ctors = Object.keys(component[FUNCTIONAL_OPTIONS]._Ctor);
357+
return Ctors.some(function (c) { return Ctor[c] === component[FUNCTIONAL_OPTIONS]._Ctor[c]; })
349358
}
350359

351360
function findVueComponents (
@@ -354,10 +363,10 @@ function findVueComponents (
354363
selector
355364
) {
356365
if (selector.functional) {
357-
var components$1 = root._vnode
366+
var nodes = root._vnode
358367
? findAllFunctionalComponentsFromVnode(root._vnode)
359368
: findAllFunctionalComponentsFromVnode(root);
360-
return components$1.filter(function (component) { return vmFunctionalCtorMatchesSelector(component, selector._Ctor); })
369+
return nodes.filter(function (node) { return vmFunctionalCtorMatchesSelector(node, selector._Ctor); })
361370
}
362371
var components = root._isVue
363372
? findAllVueComponentsFromVm(root)
@@ -932,6 +941,8 @@ Wrapper.prototype.hasProp = function hasProp (prop, value) {
932941
* Checks if wrapper has a style with value
933942
*/
934943
Wrapper.prototype.hasStyle = function hasStyle (style, value) {
944+
warn('hasStyle() has been deprecated and will be removed in version 1.0.0. Use wrapper.element.style instead');
945+
935946
if (typeof style !== 'string') {
936947
throwError('wrapper.hasStyle() must be passed style as a string');
937948
}
@@ -3883,12 +3894,12 @@ function update () {
38833894
if (this.$_mountingOptionsSlots) {
38843895
addSlots(this, this.$_mountingOptionsSlots);
38853896
}
3886-
var vnodes = this._render();
3887-
this._update(vnodes);
3888-
this.$children.forEach(function (child) { return update.call(child); });
38893897
this._watchers.forEach(function (watcher) {
38903898
watcher.run();
38913899
});
3900+
var vnodes = this._render();
3901+
this._update(vnodes);
3902+
this.$children.forEach(function (child) { return update.call(child); });
38923903
}
38933904

38943905
var VueWrapper = (function (Wrapper$$1) {
@@ -3921,7 +3932,11 @@ var VueWrapper = (function (Wrapper$$1) {
39213932
//
39223933
function addMocks (mockedProperties, Vue$$1) {
39233934
Object.keys(mockedProperties).forEach(function (key) {
3924-
Vue$$1.prototype[key] = mockedProperties[key];
3935+
try {
3936+
Vue$$1.prototype[key] = mockedProperties[key];
3937+
} catch (e) {
3938+
warn('could not overwrite property $store, this usually caused by a plugin that has added the property as a read-only value');
3939+
}
39253940
Vue.util.defineReactive(Vue$$1, key, mockedProperties[key]);
39263941
});
39273942
}
@@ -3987,6 +4002,14 @@ function addEventLogger (vue) {
39874002
//
39884003

39894004
function compileTemplate (component) {
4005+
if (component.components) {
4006+
Object.keys(component.components).forEach(function (c) {
4007+
var cmp = component.components[c];
4008+
if (!cmp.render) {
4009+
compileTemplate(cmp);
4010+
}
4011+
});
4012+
}
39904013
if (component.extends) {
39914014
compileTemplate(component.extends);
39924015
}

dist/vue-test-utils.umd.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ function createComponentStubsForAll (component) {
134134
Object.keys(component.components).forEach(function (c) {
135135
// Remove cached constructor
136136
delete component.components[c]._Ctor;
137+
if (!component.components[c].name) {
138+
component.components[c].name = c;
139+
}
137140
components[c] = createBlankStub(component.components[c]);
138141

139142
// ignoreElements does not exist in Vue 2.0.x
@@ -248,6 +251,8 @@ var NAME_SELECTOR = 'NAME_SELECTOR';
248251
var COMPONENT_SELECTOR = 'COMPONENT_SELECTOR';
249252
var REF_SELECTOR = 'REF_SELECTOR';
250253
var DOM_SELECTOR = 'DOM_SELECTOR';
254+
var VUE_VERSION = Number(((Vue.version.split('.')[0]) + "." + (Vue.version.split('.')[1])));
255+
var FUNCTIONAL_OPTIONS = VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
251256

252257
//
253258

@@ -316,7 +321,7 @@ function findAllFunctionalComponentsFromVnode (
316321
) {
317322
if ( components === void 0 ) components = [];
318323

319-
if (vnode.fnOptions) {
324+
if (vnode[FUNCTIONAL_OPTIONS] || vnode.functionalContext) {
320325
components.push(vnode);
321326
}
322327
if (vnode.children) {
@@ -342,11 +347,15 @@ function vmCtorMatchesSelector (component, selector) {
342347
}
343348

344349
function vmFunctionalCtorMatchesSelector (component, Ctor) {
345-
if (!component.fnOptions) {
350+
if (VUE_VERSION < 2.3) {
351+
throwError('find for functional components is not support in Vue < 2.3');
352+
}
353+
354+
if (!component[FUNCTIONAL_OPTIONS]) {
346355
return false
347356
}
348-
var Ctors = Object.keys(component.fnOptions._Ctor);
349-
return Ctors.some(function (c) { return Ctor[c] === component.fnOptions._Ctor[c]; })
357+
var Ctors = Object.keys(component[FUNCTIONAL_OPTIONS]._Ctor);
358+
return Ctors.some(function (c) { return Ctor[c] === component[FUNCTIONAL_OPTIONS]._Ctor[c]; })
350359
}
351360

352361
function findVueComponents (
@@ -355,10 +364,10 @@ function findVueComponents (
355364
selector
356365
) {
357366
if (selector.functional) {
358-
var components$1 = root._vnode
367+
var nodes = root._vnode
359368
? findAllFunctionalComponentsFromVnode(root._vnode)
360369
: findAllFunctionalComponentsFromVnode(root);
361-
return components$1.filter(function (component) { return vmFunctionalCtorMatchesSelector(component, selector._Ctor); })
370+
return nodes.filter(function (node) { return vmFunctionalCtorMatchesSelector(node, selector._Ctor); })
362371
}
363372
var components = root._isVue
364373
? findAllVueComponentsFromVm(root)
@@ -933,6 +942,8 @@ Wrapper.prototype.hasProp = function hasProp (prop, value) {
933942
* Checks if wrapper has a style with value
934943
*/
935944
Wrapper.prototype.hasStyle = function hasStyle (style, value) {
945+
warn('hasStyle() has been deprecated and will be removed in version 1.0.0. Use wrapper.element.style instead');
946+
936947
if (typeof style !== 'string') {
937948
throwError('wrapper.hasStyle() must be passed style as a string');
938949
}
@@ -3884,12 +3895,12 @@ function update () {
38843895
if (this.$_mountingOptionsSlots) {
38853896
addSlots(this, this.$_mountingOptionsSlots);
38863897
}
3887-
var vnodes = this._render();
3888-
this._update(vnodes);
3889-
this.$children.forEach(function (child) { return update.call(child); });
38903898
this._watchers.forEach(function (watcher) {
38913899
watcher.run();
38923900
});
3901+
var vnodes = this._render();
3902+
this._update(vnodes);
3903+
this.$children.forEach(function (child) { return update.call(child); });
38933904
}
38943905

38953906
var VueWrapper = (function (Wrapper$$1) {
@@ -3922,7 +3933,11 @@ var VueWrapper = (function (Wrapper$$1) {
39223933
//
39233934
function addMocks (mockedProperties, Vue$$1) {
39243935
Object.keys(mockedProperties).forEach(function (key) {
3925-
Vue$$1.prototype[key] = mockedProperties[key];
3936+
try {
3937+
Vue$$1.prototype[key] = mockedProperties[key];
3938+
} catch (e) {
3939+
warn('could not overwrite property $store, this usually caused by a plugin that has added the property as a read-only value');
3940+
}
39263941
Vue.util.defineReactive(Vue$$1, key, mockedProperties[key]);
39273942
});
39283943
}
@@ -3988,6 +4003,14 @@ function addEventLogger (vue) {
39884003
//
39894004

39904005
function compileTemplate (component) {
4006+
if (component.components) {
4007+
Object.keys(component.components).forEach(function (c) {
4008+
var cmp = component.components[c];
4009+
if (!cmp.render) {
4010+
compileTemplate(cmp);
4011+
}
4012+
});
4013+
}
39914014
if (component.extends) {
39924015
compileTemplate(component.extends);
39934016
}

0 commit comments

Comments
 (0)