Skip to content

Commit 3b8b1aa

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into working
# Conflicts: # docs/LANGS.md # docs/en/README.md # docs/en/SUMMARY.md # docs/en/guides/README.md Signed-off-by: Bruno Lesieur <[email protected]>
2 parents 5ba7491 + 08f58ee commit 3b8b1aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2953
-110
lines changed

build/build.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ rollup({
4949
name: 'globals',
5050
dest: resolve('dist/vue-test-utils.iife.js'),
5151
moduleName: 'vueTestUtils',
52-
format: 'iife'
52+
format: 'iife',
53+
globals: {
54+
'vue': 'Vue',
55+
'vue-template-compiler': 'VueTemplateCompiler'
56+
}
5357
})
5458
})
5559
.then(() => success('IIFE build successful'))
@@ -71,7 +75,11 @@ rollup({
7175
}).then((bundle) => {
7276
bundle.write({
7377
dest: resolve('dist/vue-test-utils.amd.js'),
74-
format: 'amd'
78+
format: 'amd',
79+
globals: {
80+
'vue': 'Vue',
81+
'vue-template-compiler': 'VueTemplateCompiler'
82+
}
7583
})
7684
})
7785
.then(() => success('AMD build successful'))
@@ -94,6 +102,10 @@ rollup({
94102
bundle.write({
95103
dest: resolve('dist/vue-test-utils.umd.js'),
96104
format: 'umd',
105+
globals: {
106+
'vue': 'Vue',
107+
'vue-template-compiler': 'VueTemplateCompiler'
108+
},
97109
moduleName: 'vueTestUtils'
98110
})
99111
})

dist/vue-test-utils.amd.js

+33-23
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@ define(['vue', 'vue-template-compiler'], function (Vue, vueTemplateCompiler) { '
22

33
Vue = Vue && 'default' in Vue ? Vue['default'] : Vue;
44

5+
//
6+
7+
function throwError (msg) {
8+
throw new Error(("[vue-test-utils]: " + msg))
9+
}
10+
11+
function warn (msg) {
12+
console.error(("[vue-test-utils]: " + msg));
13+
}
14+
15+
if (typeof window === 'undefined') {
16+
throwError(
17+
'window is undefined, vue-test-utils needs to be run in a browser environment.\n' +
18+
'You can run the tests in node using jsdom + jsdom-global.\n' +
19+
'See https://vue-test-utils.vuejs.org/en/guides/common-tips.html for more details.'
20+
);
21+
}
22+
523
/**
624
* Removes all key-value entries from the list cache.
725
*
@@ -2537,16 +2555,6 @@ var cloneDeep_1 = cloneDeep;
25372555

25382556
//
25392557

2540-
function throwError (msg) {
2541-
throw new Error(("[vue-test-utils]: " + msg))
2542-
}
2543-
2544-
function warn (msg) {
2545-
console.error(("[vue-test-utils]: " + msg));
2546-
}
2547-
2548-
//
2549-
25502558
var LIFECYCLE_HOOKS = [
25512559
'beforeCreate',
25522560
'created',
@@ -3134,11 +3142,18 @@ Wrapper.prototype.hasAttribute = function hasAttribute (attribute, value) {
31343142
* Asserts wrapper has a class name
31353143
*/
31363144
Wrapper.prototype.hasClass = function hasClass (className) {
3137-
if (typeof className !== 'string') {
3145+
var targetClass = className;
3146+
3147+
if (typeof targetClass !== 'string') {
31383148
throwError('wrapper.hasClass() must be passed a string');
31393149
}
31403150

3141-
return !!(this.element && this.element.classList.contains(className))
3151+
// if $style is available and has a matching target, use that instead.
3152+
if (this.vm && this.vm.$style && this.vm.$style[targetClass]) {
3153+
targetClass = this.vm.$style[targetClass];
3154+
}
3155+
3156+
return !!(this.element && this.element.classList.contains(targetClass))
31423157
};
31433158

31443159
/**
@@ -3698,15 +3713,7 @@ Vue.config.productionTip = false;
36983713
function mount (component, options) {
36993714
if ( options === void 0 ) options = {};
37003715

3701-
if (!window) {
3702-
throwError(
3703-
'window is undefined, vue-test-utils needs to be run in a browser environment.\n' +
3704-
'You can run the tests in node using jsdom + jsdom-global.\n' +
3705-
'See https://vue-test-utils.vuejs.org/en/guides/common-tips.html for more details.'
3706-
);
3707-
}
3708-
3709-
var componentToMount = options.clone === false ? component : cloneDeep_1(component);
3716+
var componentToMount = options.clone === false ? component : cloneDeep_1(component.extend ? component.options : component);
37103717
// Remove cached constructor
37113718
delete componentToMount._Ctor;
37123719

@@ -3727,7 +3734,7 @@ function shallow (component, options) {
37273734
if ( options === void 0 ) options = {};
37283735

37293736
var vue = options.localVue || Vue;
3730-
var clonedComponent = cloneDeep_1(component);
3737+
var clonedComponent = cloneDeep_1(component.extend ? component.options : component);
37313738

37323739
if (clonedComponent.components) {
37333740
stubAllComponents(clonedComponent);
@@ -3768,9 +3775,12 @@ function createLocalVue () {
37683775
// compat for vue-router < 2.7.1 where it does not allow multiple installs
37693776
var use = instance.use;
37703777
instance.use = function (plugin) {
3778+
var rest = [], len = arguments.length - 1;
3779+
while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
3780+
37713781
plugin.installed = false;
37723782
plugin.install.installed = false;
3773-
use.call(instance, plugin);
3783+
use.call.apply(use, [ instance, plugin ].concat( rest ));
37743784
};
37753785
return instance
37763786
}

dist/vue-test-utils.iife.js

+34-24
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ var vueTestUtils = (function (Vue,vueTemplateCompiler) {
33

44
Vue = Vue && 'default' in Vue ? Vue['default'] : Vue;
55

6+
//
7+
8+
function throwError (msg) {
9+
throw new Error(("[vue-test-utils]: " + msg))
10+
}
11+
12+
function warn (msg) {
13+
console.error(("[vue-test-utils]: " + msg));
14+
}
15+
16+
if (typeof window === 'undefined') {
17+
throwError(
18+
'window is undefined, vue-test-utils needs to be run in a browser environment.\n' +
19+
'You can run the tests in node using jsdom + jsdom-global.\n' +
20+
'See https://vue-test-utils.vuejs.org/en/guides/common-tips.html for more details.'
21+
);
22+
}
23+
624
/**
725
* Removes all key-value entries from the list cache.
826
*
@@ -2538,16 +2556,6 @@ var cloneDeep_1 = cloneDeep;
25382556

25392557
//
25402558

2541-
function throwError (msg) {
2542-
throw new Error(("[vue-test-utils]: " + msg))
2543-
}
2544-
2545-
function warn (msg) {
2546-
console.error(("[vue-test-utils]: " + msg));
2547-
}
2548-
2549-
//
2550-
25512559
var LIFECYCLE_HOOKS = [
25522560
'beforeCreate',
25532561
'created',
@@ -3135,11 +3143,18 @@ Wrapper.prototype.hasAttribute = function hasAttribute (attribute, value) {
31353143
* Asserts wrapper has a class name
31363144
*/
31373145
Wrapper.prototype.hasClass = function hasClass (className) {
3138-
if (typeof className !== 'string') {
3146+
var targetClass = className;
3147+
3148+
if (typeof targetClass !== 'string') {
31393149
throwError('wrapper.hasClass() must be passed a string');
31403150
}
31413151

3142-
return !!(this.element && this.element.classList.contains(className))
3152+
// if $style is available and has a matching target, use that instead.
3153+
if (this.vm && this.vm.$style && this.vm.$style[targetClass]) {
3154+
targetClass = this.vm.$style[targetClass];
3155+
}
3156+
3157+
return !!(this.element && this.element.classList.contains(targetClass))
31433158
};
31443159

31453160
/**
@@ -3699,15 +3714,7 @@ Vue.config.productionTip = false;
36993714
function mount (component, options) {
37003715
if ( options === void 0 ) options = {};
37013716

3702-
if (!window) {
3703-
throwError(
3704-
'window is undefined, vue-test-utils needs to be run in a browser environment.\n' +
3705-
'You can run the tests in node using jsdom + jsdom-global.\n' +
3706-
'See https://vue-test-utils.vuejs.org/en/guides/common-tips.html for more details.'
3707-
);
3708-
}
3709-
3710-
var componentToMount = options.clone === false ? component : cloneDeep_1(component);
3717+
var componentToMount = options.clone === false ? component : cloneDeep_1(component.extend ? component.options : component);
37113718
// Remove cached constructor
37123719
delete componentToMount._Ctor;
37133720

@@ -3728,7 +3735,7 @@ function shallow (component, options) {
37283735
if ( options === void 0 ) options = {};
37293736

37303737
var vue = options.localVue || Vue;
3731-
var clonedComponent = cloneDeep_1(component);
3738+
var clonedComponent = cloneDeep_1(component.extend ? component.options : component);
37323739

37333740
if (clonedComponent.components) {
37343741
stubAllComponents(clonedComponent);
@@ -3769,9 +3776,12 @@ function createLocalVue () {
37693776
// compat for vue-router < 2.7.1 where it does not allow multiple installs
37703777
var use = instance.use;
37713778
instance.use = function (plugin) {
3779+
var rest = [], len = arguments.length - 1;
3780+
while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
3781+
37723782
plugin.installed = false;
37733783
plugin.install.installed = false;
3774-
use.call(instance, plugin);
3784+
use.call.apply(use, [ instance, plugin ].concat( rest ));
37753785
};
37763786
return instance
37773787
}
@@ -3911,4 +3921,4 @@ var index = {
39113921

39123922
return index;
39133923

3914-
}(Vue,vueTemplateCompiler));
3924+
}(Vue,VueTemplateCompiler));

dist/vue-test-utils.js

+23-13
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ function warn (msg) {
1616
console.error(("[vue-test-utils]: " + msg));
1717
}
1818

19+
if (typeof window === 'undefined') {
20+
throwError(
21+
'window is undefined, vue-test-utils needs to be run in a browser environment.\n' +
22+
'You can run the tests in node using jsdom + jsdom-global.\n' +
23+
'See https://vue-test-utils.vuejs.org/en/guides/common-tips.html for more details.'
24+
);
25+
}
26+
1927
//
2028

2129
var LIFECYCLE_HOOKS = [
@@ -605,11 +613,18 @@ Wrapper.prototype.hasAttribute = function hasAttribute (attribute, value) {
605613
* Asserts wrapper has a class name
606614
*/
607615
Wrapper.prototype.hasClass = function hasClass (className) {
608-
if (typeof className !== 'string') {
616+
var targetClass = className;
617+
618+
if (typeof targetClass !== 'string') {
609619
throwError('wrapper.hasClass() must be passed a string');
610620
}
611621

612-
return !!(this.element && this.element.classList.contains(className))
622+
// if $style is available and has a matching target, use that instead.
623+
if (this.vm && this.vm.$style && this.vm.$style[targetClass]) {
624+
targetClass = this.vm.$style[targetClass];
625+
}
626+
627+
return !!(this.element && this.element.classList.contains(targetClass))
613628
};
614629

615630
/**
@@ -1169,15 +1184,7 @@ Vue.config.productionTip = false;
11691184
function mount (component, options) {
11701185
if ( options === void 0 ) options = {};
11711186

1172-
if (!window) {
1173-
throwError(
1174-
'window is undefined, vue-test-utils needs to be run in a browser environment.\n' +
1175-
'You can run the tests in node using jsdom + jsdom-global.\n' +
1176-
'See https://vue-test-utils.vuejs.org/en/guides/common-tips.html for more details.'
1177-
);
1178-
}
1179-
1180-
var componentToMount = options.clone === false ? component : cloneDeep(component);
1187+
var componentToMount = options.clone === false ? component : cloneDeep(component.extend ? component.options : component);
11811188
// Remove cached constructor
11821189
delete componentToMount._Ctor;
11831190

@@ -1198,7 +1205,7 @@ function shallow (component, options) {
11981205
if ( options === void 0 ) options = {};
11991206

12001207
var vue = options.localVue || Vue;
1201-
var clonedComponent = cloneDeep(component);
1208+
var clonedComponent = cloneDeep(component.extend ? component.options : component);
12021209

12031210
if (clonedComponent.components) {
12041211
stubAllComponents(clonedComponent);
@@ -1239,9 +1246,12 @@ function createLocalVue () {
12391246
// compat for vue-router < 2.7.1 where it does not allow multiple installs
12401247
var use = instance.use;
12411248
instance.use = function (plugin) {
1249+
var rest = [], len = arguments.length - 1;
1250+
while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
1251+
12421252
plugin.installed = false;
12431253
plugin.install.installed = false;
1244-
use.call(instance, plugin);
1254+
use.call.apply(use, [ instance, plugin ].concat( rest ));
12451255
};
12461256
return instance
12471257
}

0 commit comments

Comments
 (0)