Skip to content

Commit 3cbc2cc

Browse files
committed
chore: build 1.1.1
1 parent c198d19 commit 3cbc2cc

File tree

5 files changed

+363
-33
lines changed

5 files changed

+363
-33
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
],
66
"npmClient": "yarn",
77
"useWorkspaces": true,
8-
"version": "1.1.0"
8+
"version": "1.1.1"
99
}

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

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8116,7 +8116,11 @@ function recursivelySetData(vm, target, data) {
81168116
var val = data[key];
81178117
var targetVal = target[key];
81188118

8119-
if (isPlainObject(val) && isPlainObject(targetVal)) {
8119+
if (
8120+
isPlainObject(val) &&
8121+
isPlainObject(targetVal) &&
8122+
Object.keys(val).length > 0
8123+
) {
81208124
recursivelySetData(vm, targetVal, val);
81218125
} else {
81228126
vm.$set(target, key, val);
@@ -9481,14 +9485,27 @@ var Wrapper = function Wrapper(
94819485
}
94829486
};
94839487

9488+
/**
9489+
* Prints warning if component is destroyed
9490+
*/
9491+
Wrapper.prototype.__warnIfDestroyed = function __warnIfDestroyed () {
9492+
if (!this.exists()) {
9493+
warn('Operations on destroyed component are discouraged');
9494+
}
9495+
};
9496+
94849497
Wrapper.prototype.at = function at () {
9498+
this.__warnIfDestroyed();
9499+
94859500
throwError('at() must be called on a WrapperArray');
94869501
};
94879502

94889503
/**
94899504
* Returns an Object containing all the attribute/value pairs on the element.
94909505
*/
94919506
Wrapper.prototype.attributes = function attributes (key) {
9507+
this.__warnIfDestroyed();
9508+
94929509
var attributes = this.element.attributes;
94939510
var attributeMap = {};
94949511
for (var i = 0; i < attributes.length; i++) {
@@ -9505,6 +9522,8 @@ Wrapper.prototype.attributes = function attributes (key) {
95059522
Wrapper.prototype.classes = function classes (className) {
95069523
var this$1 = this;
95079524

9525+
this.__warnIfDestroyed();
9526+
95089527
var classAttribute = this.element.getAttribute('class');
95099528
var classes = classAttribute ? classAttribute.split(' ') : [];
95109529
// Handle converting cssmodules identifiers back to the original class name
@@ -9535,6 +9554,9 @@ Wrapper.prototype.contains = function contains (rawSelector) {
95359554
'contains',
95369555
'Use `wrapper.find`, `wrapper.findComponent` or `wrapper.get` instead'
95379556
);
9557+
9558+
this.__warnIfDestroyed();
9559+
95389560
var selector = getSelector(rawSelector, 'contains');
95399561
var nodes = find(this.rootNode, this.vm, selector);
95409562
return nodes.length > 0
@@ -9610,23 +9632,41 @@ Wrapper.prototype.filter = function filter () {
96109632
* matches the provided selector.
96119633
*/
96129634
Wrapper.prototype.get = function get (rawSelector) {
9635+
this.__warnIfDestroyed();
9636+
96139637
var found = this.find(rawSelector);
96149638
if (found instanceof ErrorWrapper) {
96159639
throw new Error(("Unable to find " + rawSelector + " within: " + (this.html())))
96169640
}
96179641
return found
96189642
};
96199643

9644+
/**
9645+
* Gets first node in tree of the current wrapper that
9646+
* matches the provided selector.
9647+
*/
9648+
Wrapper.prototype.getComponent = function getComponent (rawSelector) {
9649+
this.__warnIfDestroyed();
9650+
9651+
var found = this.findComponent(rawSelector);
9652+
if (found instanceof ErrorWrapper) {
9653+
throw new Error(("Unable to get " + rawSelector + " within: " + (this.html())))
9654+
}
9655+
return found
9656+
};
9657+
96209658
/**
96219659
* Finds first DOM node in tree of the current wrapper that
96229660
* matches the provided selector.
96239661
*/
96249662
Wrapper.prototype.find = function find (rawSelector) {
9663+
this.__warnIfDestroyed();
9664+
96259665
var selector = getSelector(rawSelector, 'find');
96269666
if (selector.type !== DOM_SELECTOR) {
96279667
warnDeprecated(
9628-
'finding components with `find`',
9629-
'Use `findComponent` instead'
9668+
'finding components with `find` or `get`',
9669+
'Use `findComponent` and `getComponent` instead'
96309670
);
96319671
}
96329672

@@ -9638,6 +9678,8 @@ Wrapper.prototype.find = function find (rawSelector) {
96389678
* matches the provided selector.
96399679
*/
96409680
Wrapper.prototype.findComponent = function findComponent (rawSelector) {
9681+
this.__warnIfDestroyed();
9682+
96419683
var selector = getSelector(rawSelector, 'findComponent');
96429684
if (!this.vm && !this.isFunctionalComponent) {
96439685
throwError(
@@ -9671,6 +9713,8 @@ Wrapper.prototype.__find = function __find (rawSelector, selector) {
96719713
* the provided selector.
96729714
*/
96739715
Wrapper.prototype.findAll = function findAll (rawSelector) {
9716+
this.__warnIfDestroyed();
9717+
96749718
var selector = getSelector(rawSelector, 'findAll');
96759719
if (selector.type !== DOM_SELECTOR) {
96769720
warnDeprecated(
@@ -9686,6 +9730,8 @@ Wrapper.prototype.findAll = function findAll (rawSelector) {
96869730
* the provided selector.
96879731
*/
96889732
Wrapper.prototype.findAllComponents = function findAllComponents (rawSelector) {
9733+
this.__warnIfDestroyed();
9734+
96899735
var selector = getSelector(rawSelector, 'findAll');
96909736
if (!this.vm) {
96919737
throwError(
@@ -9721,13 +9767,17 @@ Wrapper.prototype.__findAll = function __findAll (rawSelector, selector) {
97219767
* Returns HTML of element as a string
97229768
*/
97239769
Wrapper.prototype.html = function html () {
9770+
this.__warnIfDestroyed();
9771+
97249772
return pretty(this.element.outerHTML)
97259773
};
97269774

97279775
/**
97289776
* Checks if node matches selector or component definition
97299777
*/
97309778
Wrapper.prototype.is = function is (rawSelector) {
9779+
this.__warnIfDestroyed();
9780+
97319781
var selector = getSelector(rawSelector, 'is');
97329782

97339783
if (selector.type === DOM_SELECTOR) {
@@ -9754,6 +9804,8 @@ Wrapper.prototype.isEmpty = function isEmpty () {
97549804
'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobeempty. ' +
97559805
'When using with findComponent, access the DOM element with findComponent(Comp).element'
97569806
);
9807+
this.__warnIfDestroyed();
9808+
97579809
if (!this.vnode) {
97589810
return this.element.innerHTML === ''
97599811
}
@@ -9778,6 +9830,8 @@ Wrapper.prototype.isEmpty = function isEmpty () {
97789830
* Checks if node is visible
97799831
*/
97809832
Wrapper.prototype.isVisible = function isVisible () {
9833+
this.__warnIfDestroyed();
9834+
97819835
return isElementVisible(this.element)
97829836
};
97839837

@@ -9787,6 +9841,8 @@ Wrapper.prototype.isVisible = function isVisible () {
97879841
*/
97889842
Wrapper.prototype.isVueInstance = function isVueInstance () {
97899843
warnDeprecated("isVueInstance");
9844+
this.__warnIfDestroyed();
9845+
97909846
return !!this.vm
97919847
};
97929848

@@ -9796,6 +9852,7 @@ Wrapper.prototype.isVueInstance = function isVueInstance () {
97969852
*/
97979853
Wrapper.prototype.name = function name () {
97989854
warnDeprecated("name");
9855+
this.__warnIfDestroyed();
97999856

98009857
if (this.vm) {
98019858
return (
@@ -9821,6 +9878,7 @@ Wrapper.prototype.overview = function overview () {
98219878
var this$1 = this;
98229879

98239880
warnDeprecated("overview");
9881+
this.__warnIfDestroyed();
98249882

98259883
if (!this.vm) {
98269884
throwError("wrapper.overview() can only be called on a Vue instance");
@@ -9907,6 +9965,7 @@ Wrapper.prototype.props = function props (key) {
99079965
if (!this.vm) {
99089966
throwError('wrapper.props() must be called on a Vue instance');
99099967
}
9968+
this.__warnIfDestroyed();
99109969

99119970
var props = {};
99129971
var keys = this.vm && this.vm.$options._propKeys;
@@ -9933,6 +9992,8 @@ Wrapper.prototype.props = function props (key) {
99339992
Wrapper.prototype.setChecked = function setChecked (checked) {
99349993
if ( checked === void 0 ) checked = true;
99359994

9995+
this.__warnIfDestroyed();
9996+
99369997
if (typeof checked !== 'boolean') {
99379998
throwError('wrapper.setChecked() must be passed a boolean');
99389999
}
@@ -9982,6 +10043,8 @@ Wrapper.prototype.setChecked = function setChecked (checked) {
998210043
* @deprecated
998310044
*/
998410045
Wrapper.prototype.setSelected = function setSelected () {
10046+
this.__warnIfDestroyed();
10047+
998510048
var tagName = this.element.tagName;
998610049

998710050
if (tagName === 'SELECT') {
@@ -10027,6 +10090,8 @@ Wrapper.prototype.setData = function setData (data) {
1002710090
throwError("wrapper.setData() can only be called on a Vue instance");
1002810091
}
1002910092

10093+
this.__warnIfDestroyed();
10094+
1003010095
recursivelySetData(this.vm, this.vm, data);
1003110096
return nextTick()
1003210097
};
@@ -10046,6 +10111,8 @@ Wrapper.prototype.setMethods = function setMethods (methods) {
1004610111
if (!this.vm) {
1004710112
throwError("wrapper.setMethods() can only be called on a Vue instance");
1004810113
}
10114+
this.__warnIfDestroyed();
10115+
1004910116
Object.keys(methods).forEach(function (key) {
1005010117
// $FlowIgnore : Problem with possibly null this.vm
1005110118
this$1.vm[key] = methods[key];
@@ -10075,6 +10142,7 @@ Wrapper.prototype.setProps = function setProps (data) {
1007510142
if (!this.vm) {
1007610143
throwError("wrapper.setProps() can only be called on a Vue instance");
1007710144
}
10145+
this.__warnIfDestroyed();
1007810146

1007910147
// Save the original "silent" config so that we can directly mutate props
1008010148
var originalConfig = Vue__default['default'].config.silent;
@@ -10148,6 +10216,7 @@ Wrapper.prototype.setValue = function setValue (value) {
1014810216
var tagName = this.element.tagName;
1014910217
// $FlowIgnore
1015010218
var type = this.attributes().type;
10219+
this.__warnIfDestroyed();
1015110220

1015210221
if (tagName === 'OPTION') {
1015310222
throwError(
@@ -10200,6 +10269,8 @@ Wrapper.prototype.setValue = function setValue (value) {
1020010269
* Return text of wrapper element
1020110270
*/
1020210271
Wrapper.prototype.text = function text () {
10272+
this.__warnIfDestroyed();
10273+
1020310274
return this.element.textContent.trim()
1020410275
};
1020510276

@@ -10209,6 +10280,8 @@ Wrapper.prototype.text = function text () {
1020910280
Wrapper.prototype.trigger = function trigger (type, options) {
1021010281
if ( options === void 0 ) options = {};
1021110282

10283+
this.__warnIfDestroyed();
10284+
1021210285
if (typeof type !== 'string') {
1021310286
throwError('wrapper.trigger() must be passed a string');
1021410287
}
@@ -13112,7 +13185,11 @@ function warnDeprecated(method, fallback) {
1311213185
if (!config.showDeprecationWarnings) { return }
1311313186
var msg = method + " is deprecated and will be removed in the next major version.";
1311413187
if (fallback) { msg += " " + fallback + "."; }
13115-
warn(msg);
13188+
if (config.deprecationWarningHandler) {
13189+
config.deprecationWarningHandler(method, msg);
13190+
} else {
13191+
warn(msg);
13192+
}
1311613193
}
1311713194

1311813195
//
@@ -13372,7 +13449,8 @@ function getCoreProperties(componentOptions) {
1337213449
style: componentOptions.style,
1337313450
normalizedStyle: componentOptions.normalizedStyle,
1337413451
nativeOn: componentOptions.nativeOn,
13375-
functional: componentOptions.functional
13452+
functional: componentOptions.functional,
13453+
abstract: componentOptions.abstract
1337613454
}
1337713455
}
1337813456

@@ -13452,6 +13530,9 @@ function createStubFromComponent(
1345213530
tagName,
1345313531
{
1345413532
ref: componentOptions.functional ? context.data.ref : undefined,
13533+
domProps: componentOptions.functional
13534+
? context.data.domProps
13535+
: undefined,
1345513536
attrs: componentOptions.functional
1345613537
? Object.assign({}, context.props,
1345713538
context.data.attrs,

0 commit comments

Comments
 (0)