@vue/test-utils
Version:
Component testing utils for Vue 3.
1,739 lines (1,681 loc) • 300 kB
JavaScript
/**
* @vue/test-utils v2.4.10
* (c) 2026 Lachlan Miller
* Released under the MIT License
*/
'use strict';
var Vue = require('vue');
var compilerDom = require('@vue/compiler-dom');
var serverRenderer = require('@vue/server-renderer');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var Vue__namespace = /*#__PURE__*/_interopNamespaceDefault(Vue);
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
class Pluggable {
constructor() {
this.installedPlugins = [];
}
install(handler, options) {
if (typeof handler !== 'function') {
console.error('plugin.install must receive a function');
handler = () => ({});
}
this.installedPlugins.push({ handler, options });
}
extend(instance) {
const invokeSetup = ({ handler, options }) => {
return handler(instance, options); // invoke the setup method passed to install
};
const bindProperty = ([property, value]) => {
instance[property] =
typeof value === 'function' ? value.bind(instance) : value;
};
const addAllPropertiesFromSetup = (setupResult) => {
setupResult = typeof setupResult === 'object' ? setupResult : {};
Object.entries(setupResult).forEach(bindProperty);
};
this.installedPlugins.map(invokeSetup).forEach(addAllPropertiesFromSetup);
}
/** For testing */
reset() {
this.installedPlugins = [];
}
}
const config = {
global: {
stubs: {
transition: true,
'transition-group': true
},
provide: {},
components: {},
config: {},
directives: {},
mixins: [],
mocks: {},
plugins: [],
renderStubDefaultSlot: false
},
plugins: {
VueWrapper: new Pluggable(),
DOMWrapper: new Pluggable()
}
};
function mergeStubs(target, source) {
if (source.stubs) {
if (Array.isArray(source.stubs)) {
source.stubs.forEach(x => (target[x] = true));
}
else {
for (const [k, v] of Object.entries(source.stubs)) {
target[k] = v;
}
}
}
}
// perform 1-level-deep-pseudo-clone merge in order to prevent config leaks
// example: vue-router overwrites globalProperties.$router
function mergeAppConfig(configGlobalConfig, mountGlobalConfig) {
return Object.assign(Object.assign(Object.assign({}, configGlobalConfig), mountGlobalConfig), { globalProperties: Object.assign(Object.assign({}, configGlobalConfig === null || configGlobalConfig === void 0 ? void 0 : configGlobalConfig.globalProperties), mountGlobalConfig === null || mountGlobalConfig === void 0 ? void 0 : mountGlobalConfig.globalProperties) });
}
function mergeGlobalProperties(mountGlobal = {}) {
var _a, _b, _c;
const stubs = {};
const configGlobal = (_a = config === null || config === void 0 ? void 0 : config.global) !== null && _a !== void 0 ? _a : {};
mergeStubs(stubs, configGlobal);
mergeStubs(stubs, mountGlobal);
const renderStubDefaultSlot = (_c = (_b = mountGlobal.renderStubDefaultSlot) !== null && _b !== void 0 ? _b : (configGlobal.renderStubDefaultSlot || (config === null || config === void 0 ? void 0 : config.renderStubDefaultSlot))) !== null && _c !== void 0 ? _c : false;
if (config.renderStubDefaultSlot === true) {
console.warn('config.renderStubDefaultSlot is deprecated, use config.global.renderStubDefaultSlot instead');
}
return {
mixins: [...(configGlobal.mixins || []), ...(mountGlobal.mixins || [])],
plugins: [...(configGlobal.plugins || []), ...(mountGlobal.plugins || [])],
stubs,
components: Object.assign(Object.assign({}, configGlobal.components), mountGlobal.components),
provide: Object.assign(Object.assign({}, configGlobal.provide), mountGlobal.provide),
mocks: Object.assign(Object.assign({}, configGlobal.mocks), mountGlobal.mocks),
config: mergeAppConfig(configGlobal.config, mountGlobal.config),
directives: Object.assign(Object.assign({}, configGlobal.directives), mountGlobal.directives),
renderStubDefaultSlot
};
}
const isObject = (obj) => !!obj && typeof obj === 'object';
function isClass(obj) {
if (!(obj instanceof Object))
return;
const isCtorClass = obj.constructor && obj.constructor.toString().substring(0, 5) === 'class';
if (!('prototype' in obj)) {
return isCtorClass;
}
const prototype = obj.prototype;
const isPrototypeCtorClass = prototype.constructor &&
prototype.constructor.toString &&
prototype.constructor.toString().substring(0, 5) === 'class';
return isCtorClass || isPrototypeCtorClass;
}
// https://stackoverflow.com/a/48218209
const mergeDeep = (target, source) => {
var _a;
if (!isObject(target) || !isObject(source)) {
return source;
}
Object.keys(source)
.concat(isClass(source)
? Object.getOwnPropertyNames((_a = Object.getPrototypeOf(source)) !== null && _a !== void 0 ? _a : {})
: Object.getOwnPropertyNames(source))
.forEach(key => {
const targetValue = target[key];
const sourceValue = source[key];
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
target[key] = sourceValue;
}
else if (sourceValue instanceof Date) {
target[key] = sourceValue;
}
else if (isObject(targetValue) && isObject(sourceValue)) {
target[key] = mergeDeep(Object.assign({}, targetValue), sourceValue);
}
else {
target[key] = sourceValue;
}
});
return target;
};
function isClassComponent(component) {
return typeof component === 'function' && '__vccOpts' in component;
}
function isComponent(component) {
return Boolean(component &&
(typeof component === 'object' || typeof component === 'function'));
}
function isFunctionalComponent(component) {
return typeof component === 'function' && !isClassComponent(component);
}
function isObjectComponent(component) {
return Boolean(component && typeof component === 'object');
}
function textContent(element) {
var _a, _b;
// we check if the element is a comment first
// to return an empty string in that case, instead of the comment content
return element.nodeType !== Node.COMMENT_NODE
? ((_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '')
: '';
}
function hasOwnProperty(obj, prop) {
// eslint-disable-next-line no-prototype-builtins
return obj.hasOwnProperty(prop);
}
function isNotNullOrUndefined(obj) {
return Boolean(obj);
}
function isRefSelector(selector) {
return typeof selector === 'object' && 'ref' in selector;
}
function convertStubsToRecord(stubs) {
if (Array.isArray(stubs)) {
// ['Foo', 'Bar'] => { Foo: true, Bar: true }
return stubs.reduce((acc, current) => {
acc[current] = true;
return acc;
}, {});
}
return stubs;
}
const isDirectiveKey = (key) => key.match(/^v[A-Z].*/);
function getComponentsFromStubs(stubs) {
const normalizedStubs = convertStubsToRecord(stubs);
return Object.fromEntries(Object.entries(normalizedStubs).filter(([key]) => !isDirectiveKey(key)));
}
function getDirectivesFromStubs(stubs) {
const normalizedStubs = convertStubsToRecord(stubs);
return Object.fromEntries(Object.entries(normalizedStubs)
.filter(([key, value]) => isDirectiveKey(key) && value !== false)
.map(([key, value]) => [key.substring(1), value]));
}
function hasSetupState(vm) {
return (vm &&
vm.$.devtoolsRawSetupState);
}
function isScriptSetup(vm) {
return (vm && vm.$.setupState.__isScriptSetup);
}
let _globalThis;
const getGlobalThis = () => {
return (_globalThis ||
(_globalThis =
typeof globalThis !== 'undefined'
? globalThis
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: {}));
};
const ignorableKeyModifiers = [
'stop',
'prevent',
'self',
'exact',
'prevent',
'capture'
];
const systemKeyModifiers = ['ctrl', 'shift', 'alt', 'meta'];
const mouseKeyModifiers = ['left', 'middle', 'right'];
const keyCodesByKeyName = {
backspace: 8,
tab: 9,
enter: 13,
esc: 27,
space: 32,
pageup: 33,
pagedown: 34,
end: 35,
home: 36,
left: 37,
up: 38,
right: 39,
down: 40,
insert: 45,
delete: 46
};
const domEvents = {
abort: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
afterprint: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
animationend: {
eventInterface: 'AnimationEvent',
bubbles: true,
cancelable: false
},
animationiteration: {
eventInterface: 'AnimationEvent',
bubbles: true,
cancelable: false
},
animationstart: {
eventInterface: 'AnimationEvent',
bubbles: true,
cancelable: false
},
appinstalled: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
/**
* @deprecated
*/
audioprocess: {
eventInterface: 'AudioProcessingEvent',
bubbles: false,
cancelable: false
},
audioend: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
audiostart: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
beforeprint: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
beforeunload: {
eventInterface: 'BeforeUnloadEvent',
bubbles: false,
cancelable: true
},
beginEvent: {
eventInterface: 'TimeEvent',
bubbles: false,
cancelable: false
},
blur: {
eventInterface: 'FocusEvent',
bubbles: false,
cancelable: false
},
boundary: {
eventInterface: 'SpeechSynthesisEvent',
bubbles: false,
cancelable: false
},
cached: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
canplay: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
canplaythrough: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
change: {
eventInterface: 'Event',
bubbles: true,
cancelable: false
},
chargingchange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
chargingtimechange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
checking: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
click: {
eventInterface: 'MouseEvent',
bubbles: true,
cancelable: true
},
close: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
complete: {
eventInterface: 'OfflineAudioCompletionEvent',
bubbles: false,
cancelable: false
},
compositionend: {
eventInterface: 'CompositionEvent',
bubbles: true,
cancelable: true
},
compositionstart: {
eventInterface: 'CompositionEvent',
bubbles: true,
cancelable: true
},
compositionupdate: {
eventInterface: 'CompositionEvent',
bubbles: true,
cancelable: false
},
contextmenu: {
eventInterface: 'MouseEvent',
bubbles: true,
cancelable: true
},
copy: {
eventInterface: 'ClipboardEvent',
bubbles: true,
cancelable: true
},
cut: {
eventInterface: 'ClipboardEvent',
bubbles: true,
cancelable: true
},
dblclick: {
eventInterface: 'MouseEvent',
bubbles: true,
cancelable: true
},
devicechange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
devicelight: {
eventInterface: 'DeviceLightEvent',
bubbles: false,
cancelable: false
},
devicemotion: {
eventInterface: 'DeviceMotionEvent',
bubbles: false,
cancelable: false
},
deviceorientation: {
eventInterface: 'DeviceOrientationEvent',
bubbles: false,
cancelable: false
},
deviceproximity: {
eventInterface: 'DeviceProximityEvent',
bubbles: false,
cancelable: false
},
dischargingtimechange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
DOMActivate: {
eventInterface: 'UIEvent',
bubbles: true,
cancelable: true
},
DOMAttributeNameChanged: {
eventInterface: 'MutationNameEvent',
bubbles: true,
cancelable: true
},
DOMAttrModified: {
eventInterface: 'MutationEvent',
bubbles: true,
cancelable: true
},
DOMCharacterDataModified: {
eventInterface: 'MutationEvent',
bubbles: true,
cancelable: true
},
DOMContentLoaded: {
eventInterface: 'Event',
bubbles: true,
cancelable: true
},
DOMElementNameChanged: {
eventInterface: 'MutationNameEvent',
bubbles: true,
cancelable: true
},
DOMFocusIn: {
eventInterface: 'FocusEvent',
bubbles: true,
cancelable: true
},
DOMFocusOut: {
eventInterface: 'FocusEvent',
bubbles: true,
cancelable: true
},
DOMNodeInserted: {
eventInterface: 'MutationEvent',
bubbles: true,
cancelable: true
},
DOMNodeInsertedIntoDocument: {
eventInterface: 'MutationEvent',
bubbles: true,
cancelable: true
},
DOMNodeRemoved: {
eventInterface: 'MutationEvent',
bubbles: true,
cancelable: true
},
DOMNodeRemovedFromDocument: {
eventInterface: 'MutationEvent',
bubbles: true,
cancelable: true
},
/**
* @deprecated
*/
DOMSubtreeModified: {
eventInterface: 'MutationEvent',
bubbles: true,
cancelable: false
},
downloading: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
drag: {
eventInterface: 'DragEvent',
bubbles: true,
cancelable: true
},
dragend: {
eventInterface: 'DragEvent',
bubbles: true,
cancelable: false
},
dragenter: {
eventInterface: 'DragEvent',
bubbles: true,
cancelable: true
},
dragleave: {
eventInterface: 'DragEvent',
bubbles: true,
cancelable: false
},
dragover: {
eventInterface: 'DragEvent',
bubbles: true,
cancelable: true
},
dragstart: {
eventInterface: 'DragEvent',
bubbles: true,
cancelable: true
},
drop: {
eventInterface: 'DragEvent',
bubbles: true,
cancelable: true
},
durationchange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
emptied: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
end: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
ended: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
endEvent: {
eventInterface: 'TimeEvent',
bubbles: false,
cancelable: false
},
error: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
focus: {
eventInterface: 'FocusEvent',
bubbles: false,
cancelable: false
},
focusin: {
eventInterface: 'FocusEvent',
bubbles: true,
cancelable: false
},
focusout: {
eventInterface: 'FocusEvent',
bubbles: true,
cancelable: false
},
fullscreenchange: {
eventInterface: 'Event',
bubbles: true,
cancelable: false
},
fullscreenerror: {
eventInterface: 'Event',
bubbles: true,
cancelable: false
},
gamepadconnected: {
eventInterface: 'GamepadEvent',
bubbles: false,
cancelable: false
},
gamepaddisconnected: {
eventInterface: 'GamepadEvent',
bubbles: false,
cancelable: false
},
gotpointercapture: {
eventInterface: 'PointerEvent',
bubbles: false,
cancelable: false
},
hashchange: {
eventInterface: 'HashChangeEvent',
bubbles: true,
cancelable: false
},
lostpointercapture: {
eventInterface: 'PointerEvent',
bubbles: false,
cancelable: false
},
input: {
eventInterface: 'Event',
bubbles: true,
cancelable: false
},
invalid: {
eventInterface: 'Event',
cancelable: true,
bubbles: false
},
keydown: {
eventInterface: 'KeyboardEvent',
bubbles: true,
cancelable: true
},
keypress: {
eventInterface: 'KeyboardEvent',
bubbles: true,
cancelable: true
},
keyup: {
eventInterface: 'KeyboardEvent',
bubbles: true,
cancelable: true
},
languagechange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
levelchange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
load: {
eventInterface: 'UIEvent',
bubbles: false,
cancelable: false
},
loadeddata: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
loadedmetadata: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
loadend: {
eventInterface: 'ProgressEvent',
bubbles: false,
cancelable: false
},
loadstart: {
eventInterface: 'ProgressEvent',
bubbles: false,
cancelable: false
},
mark: {
eventInterface: 'SpeechSynthesisEvent',
bubbles: false,
cancelable: false
},
message: {
eventInterface: 'MessageEvent',
bubbles: false,
cancelable: false
},
messageerror: {
eventInterface: 'MessageEvent',
bubbles: false,
cancelable: false
},
mousedown: {
eventInterface: 'MouseEvent',
bubbles: true,
cancelable: true
},
mouseenter: {
eventInterface: 'MouseEvent',
bubbles: false,
cancelable: false
},
mouseleave: {
eventInterface: 'MouseEvent',
bubbles: false,
cancelable: false
},
mousemove: {
eventInterface: 'MouseEvent',
bubbles: true,
cancelable: true
},
mouseout: {
eventInterface: 'MouseEvent',
bubbles: true,
cancelable: true
},
mouseover: {
eventInterface: 'MouseEvent',
bubbles: true,
cancelable: true
},
mouseup: {
eventInterface: 'MouseEvent',
bubbles: true,
cancelable: true
},
nomatch: {
eventInterface: 'SpeechRecognitionEvent',
bubbles: false,
cancelable: false
},
notificationclick: {
eventInterface: 'NotificationEvent',
bubbles: false,
cancelable: false
},
noupdate: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
obsolete: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
offline: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
online: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
open: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
orientationchange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
pagehide: {
eventInterface: 'PageTransitionEvent',
bubbles: false,
cancelable: false
},
pageshow: {
eventInterface: 'PageTransitionEvent',
bubbles: false,
cancelable: false
},
paste: {
eventInterface: 'ClipboardEvent',
bubbles: true,
cancelable: true
},
pause: {
eventInterface: 'SpeechSynthesisEvent',
bubbles: false,
cancelable: false
},
pointercancel: {
eventInterface: 'PointerEvent',
bubbles: true,
cancelable: false
},
pointerdown: {
eventInterface: 'PointerEvent',
bubbles: true,
cancelable: true
},
pointerenter: {
eventInterface: 'PointerEvent',
bubbles: false,
cancelable: false
},
pointerleave: {
eventInterface: 'PointerEvent',
bubbles: false,
cancelable: false
},
pointerlockchange: {
eventInterface: 'Event',
bubbles: true,
cancelable: false
},
pointerlockerror: {
eventInterface: 'Event',
bubbles: true,
cancelable: false
},
pointermove: {
eventInterface: 'PointerEvent',
bubbles: true,
cancelable: true
},
pointerout: {
eventInterface: 'PointerEvent',
bubbles: true,
cancelable: true
},
pointerover: {
eventInterface: 'PointerEvent',
bubbles: true,
cancelable: true
},
pointerup: {
eventInterface: 'PointerEvent',
bubbles: true,
cancelable: true
},
play: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
playing: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
popstate: {
eventInterface: 'PopStateEvent',
bubbles: true,
cancelable: false
},
progress: {
eventInterface: 'ProgressEvent',
bubbles: false,
cancelable: false
},
push: {
eventInterface: 'PushEvent',
bubbles: false,
cancelable: false
},
pushsubscriptionchange: {
eventInterface: 'PushEvent',
bubbles: false,
cancelable: false
},
ratechange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
readystatechange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
repeatEvent: {
eventInterface: 'TimeEvent',
bubbles: false,
cancelable: false
},
reset: {
eventInterface: 'Event',
bubbles: true,
cancelable: true
},
resize: {
eventInterface: 'UIEvent',
bubbles: false,
cancelable: false
},
resourcetimingbufferfull: {
eventInterface: 'Performance',
bubbles: true,
cancelable: true
},
result: {
eventInterface: 'SpeechRecognitionEvent',
bubbles: false,
cancelable: false
},
resume: {
eventInterface: 'SpeechSynthesisEvent',
bubbles: false,
cancelable: false
},
scroll: {
eventInterface: 'UIEvent',
bubbles: false,
cancelable: false
},
seeked: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
seeking: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
select: {
eventInterface: 'UIEvent',
bubbles: true,
cancelable: false
},
selectstart: {
eventInterface: 'Event',
bubbles: true,
cancelable: true
},
selectionchange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
show: {
eventInterface: 'MouseEvent',
bubbles: false,
cancelable: false
},
slotchange: {
eventInterface: 'Event',
bubbles: true,
cancelable: false
},
soundend: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
soundstart: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
speechend: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
speechstart: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
stalled: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
start: {
eventInterface: 'SpeechSynthesisEvent',
bubbles: false,
cancelable: false
},
storage: {
eventInterface: 'StorageEvent',
bubbles: false,
cancelable: false
},
submit: {
eventInterface: 'Event',
bubbles: true,
cancelable: true
},
success: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
suspend: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
SVGAbort: {
eventInterface: 'SVGEvent',
bubbles: true,
cancelable: false
},
SVGError: {
eventInterface: 'SVGEvent',
bubbles: true,
cancelable: false
},
SVGLoad: {
eventInterface: 'SVGEvent',
bubbles: false,
cancelable: false
},
SVGResize: {
eventInterface: 'SVGEvent',
bubbles: true,
cancelable: false
},
SVGScroll: {
eventInterface: 'SVGEvent',
bubbles: true,
cancelable: false
},
SVGUnload: {
eventInterface: 'SVGEvent',
bubbles: false,
cancelable: false
},
SVGZoom: {
eventInterface: 'SVGZoomEvent',
bubbles: true,
cancelable: false
},
timeout: {
eventInterface: 'ProgressEvent',
bubbles: false,
cancelable: false
},
timeupdate: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
touchcancel: {
eventInterface: 'TouchEvent',
bubbles: true,
cancelable: false
},
touchend: {
eventInterface: 'TouchEvent',
bubbles: true,
cancelable: true
},
touchmove: {
eventInterface: 'TouchEvent',
bubbles: true,
cancelable: true
},
touchstart: {
eventInterface: 'TouchEvent',
bubbles: true,
cancelable: true
},
transitionend: {
eventInterface: 'TransitionEvent',
bubbles: true,
cancelable: true
},
unload: {
eventInterface: 'UIEvent',
bubbles: false,
cancelable: false
},
updateready: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
userproximity: {
eventInterface: 'UserProximityEvent',
bubbles: false,
cancelable: false
},
voiceschanged: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
visibilitychange: {
eventInterface: 'Event',
bubbles: true,
cancelable: false
},
volumechange: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
waiting: {
eventInterface: 'Event',
bubbles: false,
cancelable: false
},
wheel: {
eventInterface: 'WheelEvent',
bubbles: true,
cancelable: true
}
};
/**
* Groups modifiers into lists
*/
function generateModifiers(modifiers, isOnClick) {
const keyModifiers = [];
const systemModifiers = [];
for (let i = 0; i < modifiers.length; i++) {
const modifier = modifiers[i];
// addEventListener() options, e.g. .passive & .capture, that we dont need to handle
if (ignorableKeyModifiers.includes(modifier)) {
continue;
}
// modifiers that require special conversion
// if passed a left/right key modifier with onClick, add it here as well.
if (systemKeyModifiers.includes(modifier) ||
(mouseKeyModifiers.includes(modifier) &&
isOnClick)) {
systemModifiers.push(modifier);
}
else {
keyModifiers.push(modifier);
}
}
return {
keyModifiers,
systemModifiers
};
}
function getEventProperties(eventParams) {
const { modifiers, options = {} } = eventParams;
let { eventType } = eventParams;
const isOnClick = eventType === 'click';
const { keyModifiers, systemModifiers } = generateModifiers(modifiers, isOnClick);
if (isOnClick) {
// if it's a right click, it should fire a `contextmenu` event
if (systemModifiers.includes('right')) {
eventType = 'contextmenu';
options.button = 2;
// if its a middle click, fire a `mouseup` event
}
else if (systemModifiers.includes('middle')) {
eventType = 'mouseup';
options.button = 1;
}
}
const meta = domEvents[eventType] || {
eventInterface: 'Event',
cancelable: true,
bubbles: true
};
// convert `shift, ctrl` to `shiftKey, ctrlKey`
// allows trigger('keydown.shift.ctrl.n') directly
const systemModifiersMeta = systemModifiers.reduce((all, key) => {
all[`${key}Key`] = true;
return all;
}, {});
// get the keyCode for backwards compat
const keyCode = keyCodesByKeyName[keyModifiers[0]] ||
(options && (options.keyCode || options.code));
const eventProperties = Object.assign(Object.assign(Object.assign(Object.assign({}, systemModifiersMeta), options), { bubbles: meta.bubbles, cancelable: meta.cancelable,
// Any derived options should go here
keyCode, code: options.code || keyCode }), (keyModifiers[0] ? { key: keyModifiers[0] } : {}));
return {
eventProperties,
meta,
eventType
};
}
function createEvent(eventParams) {
const { eventProperties, meta, eventType } = getEventProperties(eventParams);
// user defined eventInterface
const eventInterface = meta.eventInterface;
const metaEventInterface = window[eventInterface];
const SupportedEventInterface = typeof metaEventInterface === 'function' ? metaEventInterface : window.Event;
return new SupportedEventInterface(eventType,
// event properties can only be added when the event is instantiated
// custom properties must be added after the event has been instantiated
eventProperties);
}
function createDOMEvent(eventString, options) {
// split eventString like `keydown.ctrl.shift` into `keydown` and array of modifiers
const [eventType, ...modifiers] = eventString.split('.');
const eventParams = {
eventType: eventType,
modifiers: modifiers,
options
};
const event = createEvent(eventParams);
const eventPrototype = Object.getPrototypeOf(event);
// attach custom options to the event, like `relatedTarget` and so on.
if (options) {
Object.keys(options).forEach(key => {
const propertyDescriptor = Object.getOwnPropertyDescriptor(eventPrototype, key);
const canSetProperty = !(propertyDescriptor && propertyDescriptor.set === undefined);
if (canSetProperty) {
event[key] = options[key];
}
});
}
return event;
}
// Stubbing occurs when in vnode transformer we're swapping
// component vnode type due to stubbing either component
// or directive on component
// In order to be able to find components we need to track pairs
// stub --> original component
// Having this as global might feel unsafe at first point
// One can assume that sharing stub map across mounts might
// lead to false matches, however our vnode mappers always
// produce new nodeTypes for each mount even if you're reusing
// same stub, so we're safe and do not need to pass these stubs
// for each mount operation
const stubs = new WeakMap();
function registerStub({ source, stub }) {
stubs.set(stub, source);
}
function getOriginalComponentFromStub(stub) {
return stubs.get(stub);
}
const cacheStringFunction = (fn) => {
const cache = Object.create(null);
return ((str) => {
const hit = cache[str];
return hit || (cache[str] = fn(str));
});
};
const camelizeRE = /-(\w)/g;
const camelize = cacheStringFunction((str) => {
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
});
const capitalize = cacheStringFunction((str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
});
const hyphenateRE = /\B([A-Z])/g;
const hyphenate = cacheStringFunction((str) => {
return str.replace(hyphenateRE, '-$1').toLowerCase();
});
function matchName(target, sourceName) {
const camelized = camelize(target);
const capitalized = capitalize(camelized);
return (!!sourceName &&
(sourceName === target ||
sourceName === camelized ||
sourceName === capitalized ||
capitalize(camelize(sourceName)) === capitalized));
}
function isCompatEnabled(key) {
var _a, _b;
return (_b = (_a = Vue__namespace.compatUtils) === null || _a === void 0 ? void 0 : _a.isCompatEnabled(key)) !== null && _b !== void 0 ? _b : false;
}
function isLegacyExtendedComponent(component) {
if (!isCompatEnabled('GLOBAL_EXTEND') || typeof component !== 'function') {
return false;
}
return (hasOwnProperty(component, 'super') &&
component.super.extend({}).super === component.super);
}
function unwrapLegacyVueExtendComponent(selector) {
return isLegacyExtendedComponent(selector) ? selector.options : selector;
}
function isLegacyFunctionalComponent(component) {
return Boolean(component &&
typeof component === 'object' &&
hasOwnProperty(component, 'functional') &&
component.functional);
}
const getComponentNameInSetup = (instance, type) => Object.keys((instance === null || instance === void 0 ? void 0 : instance.setupState) || {}).find(key => { var _a; return ((_a = Object.getOwnPropertyDescriptor(instance.setupState, key)) === null || _a === void 0 ? void 0 : _a.value) === type; });
const getComponentRegisteredName = (instance, type) => {
if (!instance || !instance.parent)
return null;
// try to infer the name based on local resolution
const registry = instance.type.components;
for (const key in registry) {
if (registry[key] === type) {
return key;
}
}
// try to retrieve name imported in script setup
return getComponentNameInSetup(instance.parent, type) || null;
};
const getComponentName = (instance, type) => {
if (isObjectComponent(type)) {
return (
// If the component we stub is a script setup component and is automatically
// imported by unplugin-vue-components we can only get its name through
// the `__name` property.
getComponentNameInSetup(instance, type) || type.name || type.__name || '');
}
if (isLegacyExtendedComponent(type)) {
return unwrapLegacyVueExtendComponent(type).name || '';
}
if (isFunctionalComponent(type)) {
return type.displayName || type.name;
}
return '';
};
/**
* Detect whether a selector matches a VNode
* @param node
* @param selector
* @return {boolean | ((value: any) => boolean)}
*/
function matches(node, rawSelector) {
var _a, _b, _c;
const selector = unwrapLegacyVueExtendComponent(rawSelector);
// do not return none Vue components
if (!node.component)
return false;
const nodeType = node.type;
if (!isComponent(nodeType))
return false;
if (typeof selector === 'string') {
return (_b = (_a = node.el) === null || _a === void 0 ? void 0 : _a.matches) === null || _b === void 0 ? void 0 : _b.call(_a, selector);
}
// When we're using stubs we want user to be able to
// find stubbed components both by original component
// or stub definition. That's why we are trying to
// extract original component and also stub, which was
// used to create specialized stub for render
const nodeTypeCandidates = [
nodeType,
getOriginalComponentFromStub(nodeType)
].filter(Boolean);
// our selector might be a stub itself
const target = (_c = getOriginalComponentFromStub(selector)) !== null && _c !== void 0 ? _c : selector;
if (nodeTypeCandidates.includes(target)) {
return true;
}
let componentName;
componentName = getComponentName(node.component, nodeType);
let selectorName = selector.name;
// the component and selector both have a name
if (componentName && selectorName) {
return matchName(selectorName, componentName);
}
componentName =
getComponentRegisteredName(node.component, nodeType) || undefined;
// if a name is missing, then check the locally registered components in the parent
if (node.component.parent) {
const registry = node.component.parent.type.components;
for (const key in registry) {
// is it the selector
if (!selectorName && registry[key] === selector) {
selectorName = key;
}
// is it the component
if (!componentName && registry[key] === nodeType) {
componentName = key;
}
}
}
if (selectorName && componentName) {
return matchName(selectorName, componentName);
}
return false;
}
/**
* Filters out the null, undefined and primitive values,
* to only keep VNode and VNodeArrayChildren values
* @param value
*/
function nodesAsObject(value) {
return !!value && typeof value === 'object';
}
/**
* Collect all children
* @param nodes
* @param children
*/
function aggregateChildren(nodes, children) {
if (children && Array.isArray(children)) {
const reversedNodes = [...children].reverse().filter(nodesAsObject);
reversedNodes.forEach((node) => {
if (Array.isArray(node)) {
aggregateChildren(nodes, node);
}
else {
nodes.unshift(node);
}
});
}
}
function findAllVNodes(vnode, selector) {
const matchingNodes = [];
const nodes = [vnode];
while (nodes.length) {
const node = nodes.shift();
aggregateChildren(nodes, node.children);
if (node.component) {
aggregateChildren(nodes, [node.component.subTree]);
}
if (node.suspense) {
// match children if component is Suspense
const { activeBranch } = node.suspense;
aggregateChildren(nodes, [activeBranch]);
}
if (matches(node, selector) && !matchingNodes.includes(node)) {
matchingNodes.push(node);
}
}
return matchingNodes;
}
function find(root, selector) {
let matchingVNodes = findAllVNodes(root, selector);
if (typeof selector === 'string') {
// When searching by CSS selector we want only one (topmost) vnode for each el`
matchingVNodes = matchingVNodes.filter((vnode) => { var _a; return ((_a = vnode.component.parent) === null || _a === void 0 ? void 0 : _a.vnode.el) !== vnode.el; });
}
return matchingVNodes.map((vnode) => vnode.component);
}
function createWrapperError(wrapperType) {
return new Proxy(Object.create(null), {
get(obj, prop) {
switch (prop) {
case 'then':
// allows for better errors when wrapping `find` in `await`
// https://github.com/vuejs/test-utils/issues/638
return;
case 'exists':
return () => false;
default:
throw new Error(`Cannot call ${String(prop)} on an empty ${wrapperType}.`);
}
}
});
}
/*!
* isElementVisible
* Adapted from https://github.com/testing-library/jest-dom
* Licensed under the MIT License.
*/
function isStyleVisible(element) {
if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) {
return false;
}
const { display, visibility, opacity } = getComputedStyle(element);
return (display !== 'none' &&
visibility !== 'hidden' &&
visibility !== 'collapse' &&
opacity !== '0');
}
function isAttributeVisible(element) {
return (!element.hasAttribute('hidden') &&
(element.nodeName === 'DETAILS' ? element.hasAttribute('open') : true));
}
function isElementVisible(element) {
return (element.nodeName !== '#comment' &&
isStyleVisible(element) &&
isAttributeVisible(element) &&
(!element.parentElement || isElementVisible(element.parentElement)));
}
function isElement(element) {
return element instanceof Element;
}
var WrapperType;
(function (WrapperType) {
WrapperType[WrapperType["DOMWrapper"] = 0] = "DOMWrapper";
WrapperType[WrapperType["VueWrapper"] = 1] = "VueWrapper";
})(WrapperType || (WrapperType = {}));
const factories = {};
function registerFactory(type, fn) {
factories[type] = fn;
}
const createDOMWrapper = (element, subTree) => factories[WrapperType.DOMWrapper](element, subTree);
const createVueWrapper = (app, vm, setProps) => factories[WrapperType.VueWrapper](app, vm, setProps);
function stringifyNode(node) {
return node instanceof Element
? node.outerHTML
: new XMLSerializer().serializeToString(node);
}
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var js = {exports: {}};
var src = {};
var javascript = {exports: {}};
var beautifier$2 = {};
var output = {};
/*jshint node:true */
var hasRequiredOutput;
function requireOutput () {
if (hasRequiredOutput) return output;
hasRequiredOutput = 1;
function OutputLine(parent) {
this.__parent = parent;
this.__character_count = 0;
// use indent_count as a marker for this.__lines that have preserved indentation
this.__indent_count = -1;
this.__alignment_count = 0;
this.__wrap_point_index = 0;
this.__wrap_point_character_count = 0;
this.__wrap_point_indent_count = -1;
this.__wrap_point_alignment_count = 0;
this.__items = [];
}
OutputLine.prototype.clone_empty = function() {
var line = new OutputLine(this.__parent);
line.set_indent(this.__indent_count, this.__alignment_count);
return line;
};
OutputLine.prototype.item = function(index) {
if (index < 0) {
return this.__items[this.__items.length + index];
} else {
return this.__items[index];
}
};
OutputLine.prototype.has_match = function(pattern) {
for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
if (this.__items[lastCheckedOutput].match(pattern)) {
return true;
}
}
return false;
};
OutputLine.prototype.set_indent = function(indent, alignment) {
if (this.is_empty()) {
this.__indent_count = indent || 0;
this.__alignment_count = alignment || 0;
this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
}
};
OutputLine.prototype._set_wrap_point = function() {
if (this.__parent.wrap_line_length) {
this.__wrap_point_index = this.__items.length;
this.__wrap_point_character_count = this.__character_count;
this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
}
};
OutputLine.prototype._should_wrap = function() {
return this.__wrap_point_index &&
this.__character_count > this.__parent.wrap_line_length &&
this.__wrap_point_character_count > this.__parent.next_line.__character_count;
};
OutputLine.prototype._allow_wrap = function() {
if (this._should_wrap()) {
this.__parent.add_new_line();
var next = this.__parent.current_line;
next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
next.__items = this.__items.slice(this.__wrap_point_index);
this.__items = this.__items.slice(0, this.__wrap_point_index);
next.__character_count += this.__character_count - this.__wrap_point_character_count;
this.__character_count = this.__wrap_point_character_count;
if (next.__items[0] === " ") {
next.__items.splice(0, 1);
next.__character_count -= 1;
}
return true;
}
return false;
};
OutputLine.prototype.is_empty = function() {
return this.__items.length === 0;
};
OutputLine.prototype.last = function() {
if (!this.is_empty()) {
return this.__items[this.__items.length - 1];
} else {
return null;
}
};
OutputLine.prototype.push = function(item) {
this.__items.push(item);
var last_newline_index = item.lastIndexOf('\n');
if (last_newline_index !== -1) {
this.__character_count = item.length - last_newline_index;
} else {
this.__character_count += item.length;
}
};
OutputLine.prototype.pop = function() {
var item = null;
if (!this.is_empty()) {
item = this.__items.pop();
this.__character_count -= item.length;
}
return item;
};
OutputLine.prototype._remove_indent = function() {
if (this.__indent_count > 0) {
this.__indent_count -= 1;
this.__character_count -= this.__parent.indent_size;
}
};
OutputLine.prototype._remove_wrap_indent = function() {
if (this.__wrap_point_indent_count > 0) {
this.__wrap_point_indent_count -= 1;
}
};
OutputLine.prototype.trim = function() {
while (this.last() === ' ') {
this.__items.pop();
this.__character_count -= 1;
}
};
OutputLine.prototype.toString = function() {
var result = '';
if (this.is_empty()) {
if (this.__parent.indent_empty_lines) {
result = this.__parent.get_indent_string(this.__indent_count);
}
} else {
result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
result += this.__items.join('');
}
return result;
};
function IndentStringCache(options, baseIndentString) {
this.__cache = [''];
this.__indent_size = options.indent_size;
this.__indent_string = options.indent_char;
if (!options.indent_with_tabs) {
this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
}
// Set to null to continue support for auto detection of base indent
baseIndentString = baseIndentString || '';
if (options.indent_level > 0) {
baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
}
this.__base_string = baseIndentString;
this.__base_string_length = baseIndentString.length;
}
IndentStringCache.prototype.get_indent_size = function(indent, column) {
var result = this.__base_string_length;
column = column || 0;
if (indent < 0) {
result = 0;
}
resul