Skip to content

Commit 4e44fb8

Browse files
committed
chore: publish 1.2.0
1 parent c14d6fd commit 4e44fb8

File tree

4 files changed

+136
-16
lines changed

4 files changed

+136
-16
lines changed

packages/server-test-utils/dist/vue-server-test-utils.js

+34-4
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,14 @@ function matches(node, selector) {
19311931
return element && element.matches && element.matches(selector.value)
19321932
}
19331933

1934-
var componentInstance = node[FUNCTIONAL_OPTIONS] || node.child;
1934+
var isFunctionalSelector = isConstructor(selector.value)
1935+
? selector.value.options.functional
1936+
: selector.value.functional;
1937+
1938+
var componentInstance =
1939+
(isFunctionalSelector ? node[FUNCTIONAL_OPTIONS] : node.child) ||
1940+
node[FUNCTIONAL_OPTIONS] ||
1941+
node.child;
19351942

19361943
if (!componentInstance) {
19371944
return false
@@ -9398,7 +9405,7 @@ function getOptions(eventParams) {
93989405
// Any derived options should go here
93999406
keyCode: keyCode,
94009407
code: keyCode,
9401-
key: key})
9408+
key: key || options.key})
94029409
}
94039410

94049411
function createEvent(eventParams) {
@@ -13443,6 +13450,8 @@ function createScopedSlots(
1344313450

1344413451
//
1344513452

13453+
var FUNCTION_PLACEHOLDER = '[Function]';
13454+
1344613455
function isVueComponentStub(comp) {
1344713456
return (comp && comp.template) || isVueComponent(comp)
1344813457
}
@@ -13540,10 +13549,10 @@ function createStubFromComponent(
1354013549
tagName,
1354113550
componentOptions.functional
1354213551
? Object.assign({}, context.data,
13543-
{attrs: Object.assign({}, context.props,
13552+
{attrs: Object.assign({}, shapeStubProps(context.props),
1354413553
context.data.attrs)})
1354513554
: {
13546-
attrs: Object.assign({}, this.$props)
13555+
attrs: Object.assign({}, shapeStubProps(this.$props))
1354713556
},
1354813557
context
1354913558
? context.children
@@ -13554,6 +13563,27 @@ function createStubFromComponent(
1355413563
}})
1355513564
}
1355613565

13566+
function shapeStubProps(props) {
13567+
var shapedProps = {};
13568+
for (var propName in props) {
13569+
if (typeof props[propName] === 'function') {
13570+
shapedProps[propName] = FUNCTION_PLACEHOLDER;
13571+
continue
13572+
}
13573+
13574+
if (Array.isArray(props[propName])) {
13575+
shapedProps[propName] = props[propName].map(function (value) {
13576+
return typeof value === 'function' ? FUNCTION_PLACEHOLDER : value
13577+
});
13578+
continue
13579+
}
13580+
13581+
shapedProps[propName] = props[propName];
13582+
}
13583+
13584+
return shapedProps
13585+
}
13586+
1355713587
// DEPRECATED: converts string stub to template stub.
1355813588
function createStubFromString(templateString, name) {
1355913589
warnDeprecated('Using a string for stubs');

packages/test-utils/dist/vue-test-utils.iife.js

+34-4
Original file line numberDiff line numberDiff line change
@@ -2238,6 +2238,8 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
22382238

22392239
//
22402240

2241+
var FUNCTION_PLACEHOLDER = '[Function]';
2242+
22412243
function isVueComponentStub(comp) {
22422244
return (comp && comp.template) || isVueComponent(comp)
22432245
}
@@ -2335,10 +2337,10 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
23352337
tagName,
23362338
componentOptions.functional
23372339
? Object.assign({}, context.data,
2338-
{attrs: Object.assign({}, context.props,
2340+
{attrs: Object.assign({}, shapeStubProps(context.props),
23392341
context.data.attrs)})
23402342
: {
2341-
attrs: Object.assign({}, this.$props)
2343+
attrs: Object.assign({}, shapeStubProps(this.$props))
23422344
},
23432345
context
23442346
? context.children
@@ -2349,6 +2351,27 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
23492351
}})
23502352
}
23512353

2354+
function shapeStubProps(props) {
2355+
var shapedProps = {};
2356+
for (var propName in props) {
2357+
if (typeof props[propName] === 'function') {
2358+
shapedProps[propName] = FUNCTION_PLACEHOLDER;
2359+
continue
2360+
}
2361+
2362+
if (Array.isArray(props[propName])) {
2363+
shapedProps[propName] = props[propName].map(function (value) {
2364+
return typeof value === 'function' ? FUNCTION_PLACEHOLDER : value
2365+
});
2366+
continue
2367+
}
2368+
2369+
shapedProps[propName] = props[propName];
2370+
}
2371+
2372+
return shapedProps
2373+
}
2374+
23522375
// DEPRECATED: converts string stub to template stub.
23532376
function createStubFromString(templateString, name) {
23542377
warnDeprecated('Using a string for stubs');
@@ -2736,7 +2759,14 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
27362759
return element && element.matches && element.matches(selector.value)
27372760
}
27382761

2739-
var componentInstance = node[FUNCTIONAL_OPTIONS] || node.child;
2762+
var isFunctionalSelector = isConstructor(selector.value)
2763+
? selector.value.options.functional
2764+
: selector.value.functional;
2765+
2766+
var componentInstance =
2767+
(isFunctionalSelector ? node[FUNCTIONAL_OPTIONS] : node.child) ||
2768+
node[FUNCTIONAL_OPTIONS] ||
2769+
node.child;
27402770

27412771
if (!componentInstance) {
27422772
return false
@@ -10302,7 +10332,7 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
1030210332
// Any derived options should go here
1030310333
keyCode: keyCode,
1030410334
code: keyCode,
10305-
key: key})
10335+
key: key || options.key})
1030610336
}
1030710337

1030810338
function createEvent(eventParams) {

packages/test-utils/dist/vue-test-utils.js

+34-4
Original file line numberDiff line numberDiff line change
@@ -2242,6 +2242,8 @@ function createScopedSlots(
22422242

22432243
//
22442244

2245+
var FUNCTION_PLACEHOLDER = '[Function]';
2246+
22452247
function isVueComponentStub(comp) {
22462248
return (comp && comp.template) || isVueComponent(comp)
22472249
}
@@ -2339,10 +2341,10 @@ function createStubFromComponent(
23392341
tagName,
23402342
componentOptions.functional
23412343
? Object.assign({}, context.data,
2342-
{attrs: Object.assign({}, context.props,
2344+
{attrs: Object.assign({}, shapeStubProps(context.props),
23432345
context.data.attrs)})
23442346
: {
2345-
attrs: Object.assign({}, this.$props)
2347+
attrs: Object.assign({}, shapeStubProps(this.$props))
23462348
},
23472349
context
23482350
? context.children
@@ -2353,6 +2355,27 @@ function createStubFromComponent(
23532355
}})
23542356
}
23552357

2358+
function shapeStubProps(props) {
2359+
var shapedProps = {};
2360+
for (var propName in props) {
2361+
if (typeof props[propName] === 'function') {
2362+
shapedProps[propName] = FUNCTION_PLACEHOLDER;
2363+
continue
2364+
}
2365+
2366+
if (Array.isArray(props[propName])) {
2367+
shapedProps[propName] = props[propName].map(function (value) {
2368+
return typeof value === 'function' ? FUNCTION_PLACEHOLDER : value
2369+
});
2370+
continue
2371+
}
2372+
2373+
shapedProps[propName] = props[propName];
2374+
}
2375+
2376+
return shapedProps
2377+
}
2378+
23562379
// DEPRECATED: converts string stub to template stub.
23572380
function createStubFromString(templateString, name) {
23582381
warnDeprecated('Using a string for stubs');
@@ -2740,7 +2763,14 @@ function matches(node, selector) {
27402763
return element && element.matches && element.matches(selector.value)
27412764
}
27422765

2743-
var componentInstance = node[FUNCTIONAL_OPTIONS] || node.child;
2766+
var isFunctionalSelector = isConstructor(selector.value)
2767+
? selector.value.options.functional
2768+
: selector.value.functional;
2769+
2770+
var componentInstance =
2771+
(isFunctionalSelector ? node[FUNCTIONAL_OPTIONS] : node.child) ||
2772+
node[FUNCTIONAL_OPTIONS] ||
2773+
node.child;
27442774

27452775
if (!componentInstance) {
27462776
return false
@@ -10306,7 +10336,7 @@ function getOptions(eventParams) {
1030610336
// Any derived options should go here
1030710337
keyCode: keyCode,
1030810338
code: keyCode,
10309-
key: key})
10339+
key: key || options.key})
1031010340
}
1031110341

1031210342
function createEvent(eventParams) {

packages/test-utils/dist/vue-test-utils.umd.js

+34-4
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,8 @@
22412241

22422242
//
22432243

2244+
var FUNCTION_PLACEHOLDER = '[Function]';
2245+
22442246
function isVueComponentStub(comp) {
22452247
return (comp && comp.template) || isVueComponent(comp)
22462248
}
@@ -2338,10 +2340,10 @@
23382340
tagName,
23392341
componentOptions.functional
23402342
? Object.assign({}, context.data,
2341-
{attrs: Object.assign({}, context.props,
2343+
{attrs: Object.assign({}, shapeStubProps(context.props),
23422344
context.data.attrs)})
23432345
: {
2344-
attrs: Object.assign({}, this.$props)
2346+
attrs: Object.assign({}, shapeStubProps(this.$props))
23452347
},
23462348
context
23472349
? context.children
@@ -2352,6 +2354,27 @@
23522354
}})
23532355
}
23542356

2357+
function shapeStubProps(props) {
2358+
var shapedProps = {};
2359+
for (var propName in props) {
2360+
if (typeof props[propName] === 'function') {
2361+
shapedProps[propName] = FUNCTION_PLACEHOLDER;
2362+
continue
2363+
}
2364+
2365+
if (Array.isArray(props[propName])) {
2366+
shapedProps[propName] = props[propName].map(function (value) {
2367+
return typeof value === 'function' ? FUNCTION_PLACEHOLDER : value
2368+
});
2369+
continue
2370+
}
2371+
2372+
shapedProps[propName] = props[propName];
2373+
}
2374+
2375+
return shapedProps
2376+
}
2377+
23552378
// DEPRECATED: converts string stub to template stub.
23562379
function createStubFromString(templateString, name) {
23572380
warnDeprecated('Using a string for stubs');
@@ -2739,7 +2762,14 @@
27392762
return element && element.matches && element.matches(selector.value)
27402763
}
27412764

2742-
var componentInstance = node[FUNCTIONAL_OPTIONS] || node.child;
2765+
var isFunctionalSelector = isConstructor(selector.value)
2766+
? selector.value.options.functional
2767+
: selector.value.functional;
2768+
2769+
var componentInstance =
2770+
(isFunctionalSelector ? node[FUNCTIONAL_OPTIONS] : node.child) ||
2771+
node[FUNCTIONAL_OPTIONS] ||
2772+
node.child;
27432773

27442774
if (!componentInstance) {
27452775
return false
@@ -10305,7 +10335,7 @@
1030510335
// Any derived options should go here
1030610336
keyCode: keyCode,
1030710337
code: keyCode,
10308-
key: key})
10338+
key: key || options.key})
1030910339
}
1031010340

1031110341
function createEvent(eventParams) {

0 commit comments

Comments
 (0)