-
Notifications
You must be signed in to change notification settings - Fork 668
/
Copy pathvue-test-utils.js
5574 lines (4779 loc) · 140 KB
/
vue-test-utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var Vue = _interopDefault(require('vue'));
var vueTemplateCompiler = require('vue-template-compiler');
//
function throwError (msg) {
throw new Error(("[vue-test-utils]: " + msg))
}
function warn (msg) {
console.error(("[vue-test-utils]: " + msg));
}
var camelizeRE = /-(\w)/g;
var camelize = function (str) {
var camelizedStr = str.replace(
camelizeRE,
function (_, c) { return (c ? c.toUpperCase() : ''); }
);
return camelizedStr.charAt(0).toLowerCase() + camelizedStr.slice(1)
};
/**
* Capitalize a string.
*/
var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.slice(1); };
/**
* Hyphenate a camelCase string.
*/
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = function (str) { return str.replace(hyphenateRE, '-$1').toLowerCase(); };
var vueVersion = Number(
((Vue.version.split('.')[0]) + "." + (Vue.version.split('.')[1]))
);
//
function warnIfNoWindow () {
if (typeof window === 'undefined') {
throwError(
"window is undefined, vue-test-utils needs to be " +
"run in a browser environment.\n" +
("You can run the tests in node using jsdom + " +
"jsdom-global.\n") +
("See " +
"https://vue-test-utils.vuejs.org/guides/common-tips.html " +
"for more details.")
);
}
}
if (typeof Element !== 'undefined' && !Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.matchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
Element.prototype.webkitMatchesSelector ||
function (s) {
var matches = (this.document || this.ownerDocument).querySelectorAll(s);
var i = matches.length;
while (--i >= 0 && matches.item(i) !== this) {}
return i > -1
};
}
if (typeof Object.assign !== 'function') {
(function () {
Object.assign = function (target) {
var arguments$1 = arguments;
if (target === undefined || target === null) {
throw new TypeError('Cannot convert undefined or null to object')
}
var output = Object(target);
for (var index = 1; index < arguments.length; index++) {
var source = arguments$1[index];
if (source !== undefined && source !== null) {
for (var nextKey in source) {
if (source.hasOwnProperty(nextKey)) {
output[nextKey] = source[nextKey];
}
}
}
}
return output
};
})();
}
//
function isDomSelector (selector) {
if (typeof selector !== 'string') {
return false
}
try {
if (typeof document === 'undefined') {
throwError(
"mount must be run in a browser environment like " +
"PhantomJS, jsdom or chrome"
);
}
} catch (error) {
throwError(
"mount must be run in a browser environment like " +
"PhantomJS, jsdom or chrome"
);
}
try {
document.querySelector(selector);
return true
} catch (error) {
return false
}
}
function isVueComponent (component) {
if (typeof component === 'function' && component.options) {
return true
}
if (component === null || typeof component !== 'object') {
return false
}
if (component.extends || component._Ctor) {
return true
}
if (typeof component.template === 'string') {
return true
}
return typeof component.render === 'function'
}
function componentNeedsCompiling (component) {
return (
component &&
!component.render &&
(component.template || component.extends || component.extendOptions) &&
!component.functional
)
}
function isRefSelector (refOptionsObject) {
if (
typeof refOptionsObject !== 'object' ||
Object.keys(refOptionsObject || {}).length !== 1
) {
return false
}
return typeof refOptionsObject.ref === 'string'
}
function isNameSelector (nameOptionsObject) {
if (typeof nameOptionsObject !== 'object' || nameOptionsObject === null) {
return false
}
return !!nameOptionsObject.name
}
function templateContainsComponent (
template,
name
) {
return [capitalize, camelize, hyphenate].some(function (format) {
var re = new RegExp(("<" + (format(name)) + "\\s*(\\s|>|(/>))"), 'g');
return re.test(template)
})
}
function isPlainObject (obj) {
return Object.prototype.toString.call(obj) === '[object Object]'
}
var NAME_SELECTOR = 'NAME_SELECTOR';
var COMPONENT_SELECTOR = 'COMPONENT_SELECTOR';
var REF_SELECTOR = 'REF_SELECTOR';
var DOM_SELECTOR = 'DOM_SELECTOR';
var VUE_VERSION = Number(
((Vue.version.split('.')[0]) + "." + (Vue.version.split('.')[1]))
);
var FUNCTIONAL_OPTIONS =
VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
//
function getSelectorTypeOrThrow (
selector,
methodName
) {
if (isDomSelector(selector)) { return DOM_SELECTOR }
if (isNameSelector(selector)) { return NAME_SELECTOR }
if (isVueComponent(selector)) { return COMPONENT_SELECTOR }
if (isRefSelector(selector)) { return REF_SELECTOR }
throwError(
"wrapper." + methodName + "() must be passed a valid CSS selector, " +
"Vue constructor, or valid find option object"
);
}
//
function getRealChild (vnode) {
var compOptions = vnode && vnode.componentOptions;
if (compOptions && compOptions.Ctor.options.abstract) {
return getRealChild(getFirstComponentChild(compOptions.children))
} else {
return vnode
}
}
function isSameChild (child, oldChild) {
return oldChild.key === child.key && oldChild.tag === child.tag
}
function getFirstComponentChild (children) {
if (Array.isArray(children)) {
for (var i = 0; i < children.length; i++) {
var c = children[i];
if (c && (c.componentOptions || isAsyncPlaceholder(c))) {
return c
}
}
}
}
function isPrimitive (value) {
return (
typeof value === 'string' ||
typeof value === 'number' ||
// $FlowIgnore
typeof value === 'symbol' ||
typeof value === 'boolean'
)
}
function isAsyncPlaceholder (node) {
return node.isComment && node.asyncFactory
}
function hasParentTransition (vnode) {
while ((vnode = vnode.parent)) {
if (vnode.data.transition) {
return true
}
}
}
var TransitionStub = {
render: function render (h) {
var children = this.$options._renderChildren;
if (!children) {
return
}
// filter out text nodes (possible whitespaces)
children = children.filter(function (c) { return c.tag || isAsyncPlaceholder(c); });
/* istanbul ignore if */
if (!children.length) {
return
}
// warn multiple elements
if (children.length > 1) {
warn(
"<transition> can only be used on a single element. " + "Use " +
'<transition-group> for lists.'
);
}
var mode = this.mode;
// warn invalid mode
if (mode && mode !== 'in-out' && mode !== 'out-in'
) {
warn(
'invalid <transition> mode: ' + mode
);
}
var rawChild = children[0];
// if this is a component root node and the component's
// parent container node also has transition, skip.
if (hasParentTransition(this.$vnode)) {
return rawChild
}
// apply transition data to child
// use getRealChild() to ignore abstract components e.g. keep-alive
var child = getRealChild(rawChild);
if (!child) {
return rawChild
}
var id = "__transition-" + (this._uid) + "-";
child.key = child.key == null
? child.isComment
? id + 'comment'
: id + child.tag
: isPrimitive(child.key)
? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
: child.key;
var data = (child.data || (child.data = {}));
var oldRawChild = this._vnode;
var oldChild = getRealChild(oldRawChild);
if (child.data.directives &&
child.data.directives.some(function (d) { return d.name === 'show'; })) {
child.data.show = true;
}
// mark v-show
// so that the transition module can hand over the control
// to the directive
if (child.data.directives &&
child.data.directives.some(function (d) { return d.name === 'show'; })) {
child.data.show = true;
}
if (
oldChild &&
oldChild.data &&
!isSameChild(child, oldChild) &&
!isAsyncPlaceholder(oldChild) &&
// #6687 component root is a comment node
!(oldChild.componentInstance &&
oldChild.componentInstance._vnode.isComment)
) {
oldChild.data = Object.assign({}, data);
}
return rawChild
}
}
//
var TransitionGroupStub = {
render: function render (h) {
var tag = this.tag || this.$vnode.data.tag || 'span';
var children = this.$slots.default || [];
return h(tag, null, children)
}
}
var config = {
stubs: {
transition: TransitionStub,
'transition-group': TransitionGroupStub
},
mocks: {},
methods: {},
provide: {},
logModifiedComponents: true,
silent: true
}
//
function findAllVueComponentsFromVm (
vm,
components
) {
if ( components === void 0 ) components = [];
components.push(vm);
vm.$children.forEach(function (child) {
findAllVueComponentsFromVm(child, components);
});
return components
}
function findAllVueComponentsFromVnode (
vnode,
components
) {
if ( components === void 0 ) components = [];
if (vnode.child) {
components.push(vnode.child);
}
if (vnode.children) {
vnode.children.forEach(function (child) {
findAllVueComponentsFromVnode(child, components);
});
}
return components
}
function findAllFunctionalComponentsFromVnode (
vnode,
components
) {
if ( components === void 0 ) components = [];
if (vnode[FUNCTIONAL_OPTIONS] || vnode.functionalContext) {
components.push(vnode);
}
if (vnode.children) {
vnode.children.forEach(function (child) {
findAllFunctionalComponentsFromVnode(child, components);
});
}
return components
}
function vmCtorMatchesName (vm, name) {
return !!(
name && (
(vm._vnode &&
vm._vnode.functionalOptions &&
vm._vnode.functionalOptions.name === name) ||
(vm.$options && vm.$options.name === name) ||
(vm.options && vm.options.name === name)
))
}
function vmCtorMatchesSelector (
component,
selector
) {
var Ctor = selector._Ctor || (selector.options && selector.options._Ctor);
if (!Ctor) {
return false
}
var constructor = component.__proto__.constructor;
return Object.keys(Ctor || {}).some(function (c) {
return Ctor[c] === constructor || Ctor[c] === constructor.super
})
}
function vmFunctionalCtorMatchesSelector (
component,
Ctor
) {
if (VUE_VERSION < 2.3) {
throwError(
"find for functional components is not support in " + "Vue < 2.3"
);
}
if (!Ctor) {
return false
}
if (!component[FUNCTIONAL_OPTIONS]) {
return false
}
var Ctors = Object.keys(component[FUNCTIONAL_OPTIONS]._Ctor);
return Ctors.some(function (c) { return Ctor[c] === component[FUNCTIONAL_OPTIONS]._Ctor[c]; })
}
function findVueComponents (
root,
selectorType,
selector
) {
if (selector.functional) {
var nodes = root._vnode
? findAllFunctionalComponentsFromVnode(root._vnode)
: findAllFunctionalComponentsFromVnode(root);
return nodes.filter(
function (node) { return vmFunctionalCtorMatchesSelector(node, selector._Ctor) ||
node[FUNCTIONAL_OPTIONS].name === selector.name; }
)
}
var nameSelector =
typeof selector === 'function' ? selector.extendOptions.name : selector.name;
var components = root._isVue
? findAllVueComponentsFromVm(root)
: findAllVueComponentsFromVnode(root);
return components.filter(function (component) {
if (!component.$vnode && !component.$options.extends) {
return false
}
return (
vmCtorMatchesSelector(component, selector) ||
vmCtorMatchesName(component, nameSelector)
)
})
}
//
var WrapperArray = function WrapperArray (wrappers) {
var length = wrappers.length;
// $FlowIgnore
Object.defineProperty(this, 'wrappers', {
get: function () { return wrappers; },
set: function () { return throwError('wrapperArray.wrappers is read-only'); }
});
// $FlowIgnore
Object.defineProperty(this, 'length', {
get: function () { return length; },
set: function () { return throwError('wrapperArray.length is read-only'); }
});
};
WrapperArray.prototype.at = function at (index) {
if (index > this.length - 1) {
throwError(("no item exists at " + index));
}
return this.wrappers[index]
};
WrapperArray.prototype.attributes = function attributes () {
this.throwErrorIfWrappersIsEmpty('attributes');
throwError(
"attributes must be called on a single wrapper, use " +
"at(i) to access a wrapper"
);
};
WrapperArray.prototype.classes = function classes () {
this.throwErrorIfWrappersIsEmpty('classes');
throwError(
"classes must be called on a single wrapper, use " +
"at(i) to access a wrapper"
);
};
WrapperArray.prototype.contains = function contains (selector) {
this.throwErrorIfWrappersIsEmpty('contains');
return this.wrappers.every(function (wrapper) { return wrapper.contains(selector); })
};
WrapperArray.prototype.exists = function exists () {
return this.length > 0 && this.wrappers.every(function (wrapper) { return wrapper.exists(); })
};
WrapperArray.prototype.filter = function filter (predicate) {
return new WrapperArray(this.wrappers.filter(predicate))
};
WrapperArray.prototype.visible = function visible () {
this.throwErrorIfWrappersIsEmpty('visible');
return this.length > 0 && this.wrappers.every(function (wrapper) { return wrapper.visible(); })
};
WrapperArray.prototype.emitted = function emitted () {
this.throwErrorIfWrappersIsEmpty('emitted');
throwError(
"emitted must be called on a single wrapper, use " +
"at(i) to access a wrapper"
);
};
WrapperArray.prototype.emittedByOrder = function emittedByOrder () {
this.throwErrorIfWrappersIsEmpty('emittedByOrder');
throwError(
"emittedByOrder must be called on a single wrapper, " +
"use at(i) to access a wrapper"
);
};
WrapperArray.prototype.hasAttribute = function hasAttribute (attribute, value) {
this.throwErrorIfWrappersIsEmpty('hasAttribute');
return this.wrappers.every(function (wrapper) { return wrapper.hasAttribute(attribute, value); }
)
};
WrapperArray.prototype.hasClass = function hasClass (className) {
this.throwErrorIfWrappersIsEmpty('hasClass');
return this.wrappers.every(function (wrapper) { return wrapper.hasClass(className); })
};
WrapperArray.prototype.hasProp = function hasProp (prop, value) {
this.throwErrorIfWrappersIsEmpty('hasProp');
return this.wrappers.every(function (wrapper) { return wrapper.hasProp(prop, value); })
};
WrapperArray.prototype.hasStyle = function hasStyle (style, value) {
this.throwErrorIfWrappersIsEmpty('hasStyle');
return this.wrappers.every(function (wrapper) { return wrapper.hasStyle(style, value); })
};
WrapperArray.prototype.findAll = function findAll () {
this.throwErrorIfWrappersIsEmpty('findAll');
throwError(
"findAll must be called on a single wrapper, use " +
"at(i) to access a wrapper"
);
};
WrapperArray.prototype.find = function find () {
this.throwErrorIfWrappersIsEmpty('find');
throwError(
"find must be called on a single wrapper, use at(i) " +
"to access a wrapper"
);
};
WrapperArray.prototype.html = function html () {
this.throwErrorIfWrappersIsEmpty('html');
throwError(
"html must be called on a single wrapper, use at(i) " +
"to access a wrapper"
);
};
WrapperArray.prototype.is = function is (selector) {
this.throwErrorIfWrappersIsEmpty('is');
return this.wrappers.every(function (wrapper) { return wrapper.is(selector); })
};
WrapperArray.prototype.isEmpty = function isEmpty () {
this.throwErrorIfWrappersIsEmpty('isEmpty');
return this.wrappers.every(function (wrapper) { return wrapper.isEmpty(); })
};
WrapperArray.prototype.isVisible = function isVisible () {
this.throwErrorIfWrappersIsEmpty('isVisible');
return this.wrappers.every(function (wrapper) { return wrapper.isVisible(); })
};
WrapperArray.prototype.isVueInstance = function isVueInstance () {
this.throwErrorIfWrappersIsEmpty('isVueInstance');
return this.wrappers.every(function (wrapper) { return wrapper.isVueInstance(); })
};
WrapperArray.prototype.name = function name () {
this.throwErrorIfWrappersIsEmpty('name');
throwError(
"name must be called on a single wrapper, use at(i) " +
"to access a wrapper"
);
};
WrapperArray.prototype.props = function props () {
this.throwErrorIfWrappersIsEmpty('props');
throwError(
"props must be called on a single wrapper, use " +
"at(i) to access a wrapper"
);
};
WrapperArray.prototype.text = function text () {
this.throwErrorIfWrappersIsEmpty('text');
throwError(
"text must be called on a single wrapper, use at(i) " +
"to access a wrapper"
);
};
WrapperArray.prototype.throwErrorIfWrappersIsEmpty = function throwErrorIfWrappersIsEmpty (method) {
if (this.wrappers.length === 0) {
throwError((method + " cannot be called on 0 items"));
}
};
WrapperArray.prototype.setComputed = function setComputed (computed) {
this.throwErrorIfWrappersIsEmpty('setComputed');
this.wrappers.forEach(function (wrapper) { return wrapper.setComputed(computed); });
};
WrapperArray.prototype.setData = function setData (data) {
this.throwErrorIfWrappersIsEmpty('setData');
this.wrappers.forEach(function (wrapper) { return wrapper.setData(data); });
};
WrapperArray.prototype.setMethods = function setMethods (props) {
this.throwErrorIfWrappersIsEmpty('setMethods');
this.wrappers.forEach(function (wrapper) { return wrapper.setMethods(props); });
};
WrapperArray.prototype.setProps = function setProps (props) {
this.throwErrorIfWrappersIsEmpty('setProps');
this.wrappers.forEach(function (wrapper) { return wrapper.setProps(props); });
};
WrapperArray.prototype.setValue = function setValue (value) {
this.throwErrorIfWrappersIsEmpty('setValue');
this.wrappers.forEach(function (wrapper) { return wrapper.setValue(value); });
};
WrapperArray.prototype.setChecked = function setChecked (checked) {
if ( checked === void 0 ) checked = true;
this.throwErrorIfWrappersIsEmpty('setChecked');
this.wrappers.forEach(function (wrapper) { return wrapper.setChecked(checked); });
};
WrapperArray.prototype.setSelected = function setSelected () {
this.throwErrorIfWrappersIsEmpty('setSelected');
throwError(
"setSelected must be called on a single wrapper, " +
"use at(i) to access a wrapper"
);
};
WrapperArray.prototype.trigger = function trigger (event, options) {
this.throwErrorIfWrappersIsEmpty('trigger');
this.wrappers.forEach(function (wrapper) { return wrapper.trigger(event, options); });
};
WrapperArray.prototype.update = function update () {
this.throwErrorIfWrappersIsEmpty('update');
warn(
"update has been removed. All changes are now " +
"synchrnous without calling update"
);
};
WrapperArray.prototype.destroy = function destroy () {
this.throwErrorIfWrappersIsEmpty('destroy');
this.wrappers.forEach(function (wrapper) { return wrapper.destroy(); });
};
//
var ErrorWrapper = function ErrorWrapper (selector) {
this.selector = selector;
};
ErrorWrapper.prototype.at = function at () {
throwError(
("find did not return " + (this.selector) + ", cannot call at() on empty Wrapper")
);
};
ErrorWrapper.prototype.attributes = function attributes () {
throwError(
("find did not return " + (this.selector) + ", cannot call attributes() on empty Wrapper")
);
};
ErrorWrapper.prototype.classes = function classes () {
throwError(
("find did not return " + (this.selector) + ", cannot call classes() on empty Wrapper")
);
};
ErrorWrapper.prototype.contains = function contains () {
throwError(
("find did not return " + (this.selector) + ", cannot call contains() on empty Wrapper")
);
};
ErrorWrapper.prototype.emitted = function emitted () {
throwError(
("find did not return " + (this.selector) + ", cannot call emitted() on empty Wrapper")
);
};
ErrorWrapper.prototype.emittedByOrder = function emittedByOrder () {
throwError(
("find did not return " + (this.selector) + ", cannot call emittedByOrder() on empty Wrapper")
);
};
ErrorWrapper.prototype.exists = function exists () {
return false
};
ErrorWrapper.prototype.filter = function filter () {
throwError(
("find did not return " + (this.selector) + ", cannot call filter() on empty Wrapper")
);
};
ErrorWrapper.prototype.visible = function visible () {
throwError(
("find did not return " + (this.selector) + ", cannot call visible() on empty Wrapper")
);
};
ErrorWrapper.prototype.hasAttribute = function hasAttribute () {
throwError(
("find did not return " + (this.selector) + ", cannot call hasAttribute() on empty Wrapper")
);
};
ErrorWrapper.prototype.hasClass = function hasClass () {
throwError(
("find did not return " + (this.selector) + ", cannot call hasClass() on empty Wrapper")
);
};
ErrorWrapper.prototype.hasProp = function hasProp () {
throwError(
("find did not return " + (this.selector) + ", cannot call hasProp() on empty Wrapper")
);
};
ErrorWrapper.prototype.hasStyle = function hasStyle () {
throwError(
("find did not return " + (this.selector) + ", cannot call hasStyle() on empty Wrapper")
);
};
ErrorWrapper.prototype.findAll = function findAll () {
throwError(
("find did not return " + (this.selector) + ", cannot call findAll() on empty Wrapper")
);
};
ErrorWrapper.prototype.find = function find () {
throwError(
("find did not return " + (this.selector) + ", cannot call find() on empty Wrapper")
);
};
ErrorWrapper.prototype.html = function html () {
throwError(
("find did not return " + (this.selector) + ", cannot call html() on empty Wrapper")
);
};
ErrorWrapper.prototype.is = function is () {
throwError(
("find did not return " + (this.selector) + ", cannot call is() on empty Wrapper")
);
};
ErrorWrapper.prototype.isEmpty = function isEmpty () {
throwError(
("find did not return " + (this.selector) + ", cannot call isEmpty() on empty Wrapper")
);
};
ErrorWrapper.prototype.isVisible = function isVisible () {
throwError(
("find did not return " + (this.selector) + ", cannot call isVisible() on empty Wrapper")
);
};
ErrorWrapper.prototype.isVueInstance = function isVueInstance () {
throwError(
("find did not return " + (this.selector) + ", cannot call isVueInstance() on empty Wrapper")
);
};
ErrorWrapper.prototype.name = function name () {
throwError(
("find did not return " + (this.selector) + ", cannot call name() on empty Wrapper")
);
};
ErrorWrapper.prototype.props = function props () {
throwError(
("find did not return " + (this.selector) + ", cannot call props() on empty Wrapper")
);
};
ErrorWrapper.prototype.text = function text () {
throwError(
("find did not return " + (this.selector) + ", cannot call text() on empty Wrapper")
);
};
ErrorWrapper.prototype.setComputed = function setComputed () {
throwError(
("find did not return " + (this.selector) + ", cannot call setComputed() on empty Wrapper")
);
};
ErrorWrapper.prototype.setData = function setData () {
throwError(
("find did not return " + (this.selector) + ", cannot call setData() on empty Wrapper")
);
};
ErrorWrapper.prototype.setMethods = function setMethods () {
throwError(
("find did not return " + (this.selector) + ", cannot call setMethods() on empty Wrapper")
);
};
ErrorWrapper.prototype.setProps = function setProps () {
throwError(
("find did not return " + (this.selector) + ", cannot call setProps() on empty Wrapper")
);
};
ErrorWrapper.prototype.setValue = function setValue () {
throwError(
("find did not return " + (this.selector) + ", cannot call setValue() on empty Wrapper")
);
};
ErrorWrapper.prototype.setChecked = function setChecked () {
throwError(
("find did not return " + (this.selector) + ", cannot call setChecked() on empty Wrapper")
);
};
ErrorWrapper.prototype.setSelected = function setSelected () {
throwError(
("find did not return " + (this.selector) + ", cannot call setSelected() on empty Wrapper")
);
};
ErrorWrapper.prototype.trigger = function trigger () {
throwError(
("find did not return " + (this.selector) + ", cannot call trigger() on empty Wrapper")
);
};
ErrorWrapper.prototype.update = function update () {
throwError(
"update has been removed from vue-test-utils." +
"All updates are now synchronous by default"
);
};
ErrorWrapper.prototype.destroy = function destroy () {
throwError(
("find did not return " + (this.selector) + ", cannot call destroy() on empty Wrapper")
);
};
//
function findAllVNodes (vnode, nodes) {
if ( nodes === void 0 ) nodes = [];
nodes.push(vnode);
if (Array.isArray(vnode.children)) {
vnode.children.forEach(function (childVNode) {
findAllVNodes(childVNode, nodes);
});
}
if (vnode.child) {
findAllVNodes(vnode.child._vnode, nodes);
}
return nodes
}
function removeDuplicateNodes (vNodes) {
var vNodeElms = vNodes.map(function (vNode) { return vNode.elm; });
return vNodes.filter(
function (vNode, index) { return index === vNodeElms.indexOf(vNode.elm); }
)
}
function nodeMatchesRef (node, refName) {
return node.data && node.data.ref === refName
}
function findVNodesByRef (vNode, refName) {
var nodes = findAllVNodes(vNode);
var refFilteredNodes = nodes.filter(function (node) { return nodeMatchesRef(node, refName); });
// Only return refs defined on top-level VNode to provide the same
// behavior as selecting via vm.$ref.{someRefName}
var mainVNodeFilteredNodes = refFilteredNodes.filter(
function (node) { return !!vNode.context.$refs[node.data.ref]; }
);
return removeDuplicateNodes(mainVNodeFilteredNodes)
}