Skip to content

Commit 8d17a80

Browse files
committed
build: 1.0.0-beta.3
1 parent 24c0ae6 commit 8d17a80

File tree

4 files changed

+124
-84
lines changed

4 files changed

+124
-84
lines changed

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
}

dist/vue-test-utils.umd.js

+34-24
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
(function (global, factory) {
22
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('vue'), require('vue-template-compiler')) :
33
typeof define === 'function' && define.amd ? define(['vue', 'vue-template-compiler'], factory) :
4-
(global.vueTestUtils = factory(global.Vue,global.vueTemplateCompiler));
4+
(global.vueTestUtils = factory(global.Vue,global.VueTemplateCompiler));
55
}(this, (function (Vue,vueTemplateCompiler) { 'use strict';
66

77
Vue = Vue && 'default' in Vue ? Vue['default'] : Vue;
88

9+
//
10+
11+
function throwError (msg) {
12+
throw new Error(("[vue-test-utils]: " + msg))
13+
}
14+
15+
function warn (msg) {
16+
console.error(("[vue-test-utils]: " + msg));
17+
}
18+
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+
927
/**
1028
* Removes all key-value entries from the list cache.
1129
*
@@ -2541,16 +2559,6 @@ var cloneDeep_1 = cloneDeep;
25412559

25422560
//
25432561

2544-
function throwError (msg) {
2545-
throw new Error(("[vue-test-utils]: " + msg))
2546-
}
2547-
2548-
function warn (msg) {
2549-
console.error(("[vue-test-utils]: " + msg));
2550-
}
2551-
2552-
//
2553-
25542562
var LIFECYCLE_HOOKS = [
25552563
'beforeCreate',
25562564
'created',
@@ -3138,11 +3146,18 @@ Wrapper.prototype.hasAttribute = function hasAttribute (attribute, value) {
31383146
* Asserts wrapper has a class name
31393147
*/
31403148
Wrapper.prototype.hasClass = function hasClass (className) {
3141-
if (typeof className !== 'string') {
3149+
var targetClass = className;
3150+
3151+
if (typeof targetClass !== 'string') {
31423152
throwError('wrapper.hasClass() must be passed a string');
31433153
}
31443154

3145-
return !!(this.element && this.element.classList.contains(className))
3155+
// if $style is available and has a matching target, use that instead.
3156+
if (this.vm && this.vm.$style && this.vm.$style[targetClass]) {
3157+
targetClass = this.vm.$style[targetClass];
3158+
}
3159+
3160+
return !!(this.element && this.element.classList.contains(targetClass))
31463161
};
31473162

31483163
/**
@@ -3702,15 +3717,7 @@ Vue.config.productionTip = false;
37023717
function mount (component, options) {
37033718
if ( options === void 0 ) options = {};
37043719

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

@@ -3731,7 +3738,7 @@ function shallow (component, options) {
37313738
if ( options === void 0 ) options = {};
37323739

37333740
var vue = options.localVue || Vue;
3734-
var clonedComponent = cloneDeep_1(component);
3741+
var clonedComponent = cloneDeep_1(component.extend ? component.options : component);
37353742

37363743
if (clonedComponent.components) {
37373744
stubAllComponents(clonedComponent);
@@ -3772,9 +3779,12 @@ function createLocalVue () {
37723779
// compat for vue-router < 2.7.1 where it does not allow multiple installs
37733780
var use = instance.use;
37743781
instance.use = function (plugin) {
3782+
var rest = [], len = arguments.length - 1;
3783+
while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
3784+
37753785
plugin.installed = false;
37763786
plugin.install.installed = false;
3777-
use.call(instance, plugin);
3787+
use.call.apply(use, [ instance, plugin ].concat( rest ));
37783788
};
37793789
return instance
37803790
}

0 commit comments

Comments
 (0)