@storybook/test 0.0.0-pr-23888-sha-39ed28da → 0.0.0-pr-23888-sha-8657c59a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -30
- package/dist/index.js +4 -4
- package/dist/index.mjs +5 -5
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { D } from './types-f5c02aaf.js';
|
|
1
2
|
import { TestingLibraryMatchers } from '@testing-library/jest-dom/types/matchers';
|
|
2
3
|
import * as _testing_library_user_event_dist_types_setup_directApi from '@testing-library/user-event/dist/types/setup/directApi';
|
|
3
4
|
import * as _testing_library_user_event_dist_types_setup_setup from '@testing-library/user-event/dist/types/setup/setup';
|
|
@@ -284,35 +285,6 @@ declare function stringify(object: unknown, maxDepth?: number, { maxLength, ...o
|
|
|
284
285
|
maxLength?: number;
|
|
285
286
|
}): string;
|
|
286
287
|
|
|
287
|
-
/**
|
|
288
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
289
|
-
*
|
|
290
|
-
* This source code is licensed under the MIT license found in the
|
|
291
|
-
* LICENSE file in the root directory of this source tree.
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
type DiffOptionsColor = (arg: string) => string;
|
|
295
|
-
interface DiffOptions {
|
|
296
|
-
aAnnotation?: string;
|
|
297
|
-
aColor?: DiffOptionsColor;
|
|
298
|
-
aIndicator?: string;
|
|
299
|
-
bAnnotation?: string;
|
|
300
|
-
bColor?: DiffOptionsColor;
|
|
301
|
-
bIndicator?: string;
|
|
302
|
-
changeColor?: DiffOptionsColor;
|
|
303
|
-
changeLineTrailingSpaceColor?: DiffOptionsColor;
|
|
304
|
-
commonColor?: DiffOptionsColor;
|
|
305
|
-
commonIndicator?: string;
|
|
306
|
-
commonLineTrailingSpaceColor?: DiffOptionsColor;
|
|
307
|
-
contextLines?: number;
|
|
308
|
-
emptyFirstOrLastLinePlaceholder?: string;
|
|
309
|
-
expand?: boolean;
|
|
310
|
-
includeChangeCounts?: boolean;
|
|
311
|
-
omitAnnotationLines?: boolean;
|
|
312
|
-
patchColor?: DiffOptionsColor;
|
|
313
|
-
compareKeys?: CompareKeys;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
288
|
/**
|
|
317
289
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
318
290
|
*
|
|
@@ -326,7 +298,7 @@ interface DiffOptions {
|
|
|
326
298
|
* @param options Diff options
|
|
327
299
|
* @returns
|
|
328
300
|
*/
|
|
329
|
-
declare function diff(a: any, b: any, options?:
|
|
301
|
+
declare function diff(a: any, b: any, options?: D): string | null;
|
|
330
302
|
|
|
331
303
|
type Formatter = (input: string | number | null | undefined) => string;
|
|
332
304
|
|
package/dist/index.js
CHANGED
|
@@ -21,14 +21,14 @@ ${difference}`)}return difference}function getFormatOptions(formatOptions,option
|
|
|
21
21
|
`),bDisplay.split(`
|
|
22
22
|
`),aCompare.split(`
|
|
23
23
|
`),bCompare.split(`
|
|
24
|
-
`),options)}}
|
|
25
|
-
Inner error message: ${err==null?void 0:err.message}`))}}function isAsymmetricMatcher(data){return getType(data)==="Object"&&typeof data.asymmetricMatch=="function"}function isReplaceable(obj1,obj2){let obj1Type=getType(obj1),obj2Type=getType(obj2);return obj1Type===obj2Type&&obj1Type==="Object"}function replaceAsymmetricMatcher(actual,expected,actualReplaced=new WeakSet,expectedReplaced=new WeakSet){return isReplaceable(actual,expected)?actualReplaced.has(actual)||expectedReplaced.has(expected)?{replacedActual:actual,replacedExpected:expected}:(actualReplaced.add(actual),expectedReplaced.add(expected),getOwnProperties(expected).forEach(key=>{let expectedValue=expected[key],actualValue=actual[key];if(isAsymmetricMatcher(expectedValue))expectedValue.asymmetricMatch(actualValue)&&(actual[key]=expectedValue);else if(isAsymmetricMatcher(actualValue))actualValue.asymmetricMatch(expectedValue)&&(expected[key]=actualValue);else if(isReplaceable(actualValue,expectedValue)){let replaced=replaceAsymmetricMatcher(actualValue,expectedValue,actualReplaced,expectedReplaced);actual[key]=replaced.replacedActual,expected[key]=replaced.replacedExpected}}),{replacedActual:actual,replacedExpected:expected}):{replacedActual:actual,replacedExpected:expected}}var MATCHERS_OBJECT=Symbol.for("matchers-object"),JEST_MATCHERS_OBJECT=Symbol.for("$$jest-matchers-object-storybook"),GLOBAL_EXPECT=Symbol.for("expect-global");if(!Object.prototype.hasOwnProperty.call(globalThis,MATCHERS_OBJECT)){let globalState=new WeakMap,matchers2=Object.create(null);Object.defineProperty(globalThis,MATCHERS_OBJECT,{get:()=>globalState}),Object.defineProperty(globalThis,JEST_MATCHERS_OBJECT,{configurable:!0,get:()=>({state:globalState.get(globalThis[GLOBAL_EXPECT]),matchers:matchers2})})}function getState(expect4){return globalThis[MATCHERS_OBJECT].get(expect4)}function setState(state,expect4){let map=globalThis[MATCHERS_OBJECT],current=map.get(expect4)||{};Object.assign(current,state),map.set(expect4,current)}function getMatcherUtils(){let c=()=>getColors(),EXPECTED_COLOR=c().green,RECEIVED_COLOR=c().red,INVERTED_COLOR=c().inverse,BOLD_WEIGHT=c().bold,DIM_COLOR=c().dim;function matcherHint(matcherName,received="received",expected="expected",options={}){let{comment="",isDirectExpectCall=!1,isNot=!1,promise="",secondArgument="",expectedColor=EXPECTED_COLOR,receivedColor=RECEIVED_COLOR,secondArgumentColor=EXPECTED_COLOR}=options,hint="",dimString="expect";return!isDirectExpectCall&&received!==""&&(hint+=DIM_COLOR(`${dimString}(`)+receivedColor(received),dimString=")"),promise!==""&&(hint+=DIM_COLOR(`${dimString}.`)+promise,dimString=""),isNot&&(hint+=`${DIM_COLOR(`${dimString}.`)}not`,dimString=""),matcherName.includes(".")?dimString+=matcherName:(hint+=DIM_COLOR(`${dimString}.`)+matcherName,dimString=""),expected===""?dimString+="()":(hint+=DIM_COLOR(`${dimString}(`)+expectedColor(expected),secondArgument&&(hint+=DIM_COLOR(", ")+secondArgumentColor(secondArgument)),dimString=")"),comment!==""&&(dimString+=` // ${comment}`),dimString!==""&&(hint+=DIM_COLOR(dimString)),hint}let SPACE_SYMBOL="\xB7",replaceTrailingSpaces=text=>text.replace(/\s+$/gm,spaces=>SPACE_SYMBOL.repeat(spaces.length));return{EXPECTED_COLOR,RECEIVED_COLOR,INVERTED_COLOR,BOLD_WEIGHT,DIM_COLOR,matcherHint,printReceived:object=>RECEIVED_COLOR(replaceTrailingSpaces(stringify(object))),printExpected:value=>EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)))}}function equals(a,b2,customTesters,strictCheck){return customTesters=customTesters||[],eq(a,b2,[],[],customTesters,strictCheck?hasKey:hasDefinedKey)}var functionToString=Function.prototype.toString;function isAsymmetric(obj){return!!obj&&typeof obj=="object"&&"asymmetricMatch"in obj&&isA("Function",obj.asymmetricMatch)}function asymmetricMatch(a,b2){let asymmetricA=isAsymmetric(a),asymmetricB=isAsymmetric(b2);if(!(asymmetricA&&asymmetricB)){if(asymmetricA)return a.asymmetricMatch(b2);if(asymmetricB)return b2.asymmetricMatch(a)}}function eq(a,b2,aStack,bStack,customTesters,hasKey2){let result=!0,asymmetricResult=asymmetricMatch(a,b2);if(asymmetricResult!==void 0)return asymmetricResult;for(let i2=0;i2<customTesters.length;i2++){let customTesterResult=customTesters[i2](a,b2);if(customTesterResult!==void 0)return customTesterResult}if(a instanceof Error&&b2 instanceof Error)return a.message===b2.message;if(Object.is(a,b2))return!0;if(a===null||b2===null)return a===b2;let className=Object.prototype.toString.call(a);if(className!==Object.prototype.toString.call(b2))return!1;switch(className){case"[object Boolean]":case"[object String]":case"[object Number]":return typeof a!=typeof b2?!1:typeof a!="object"&&typeof b2!="object"?Object.is(a,b2):Object.is(a.valueOf(),b2.valueOf());case"[object Date]":{let numA=+a,numB=+b2;return numA===numB||Number.isNaN(numA)&&Number.isNaN(numB)}case"[object RegExp]":return a.source===b2.source&&a.flags===b2.flags}if(typeof a!="object"||typeof b2!="object")return!1;if(isDomNode(a)&&isDomNode(b2))return a.isEqualNode(b2);let length=aStack.length;for(;length--;){if(aStack[length]===a)return bStack[length]===b2;if(bStack[length]===b2)return!1}if(aStack.push(a),bStack.push(b2),className==="[object Array]"&&a.length!==b2.length)return!1;let aKeys=keys(a,hasKey2),key,size=aKeys.length;if(keys(b2,hasKey2).length!==size)return!1;for(;size--;)if(key=aKeys[size],result=hasKey2(b2,key)&&eq(a[key],b2[key],aStack,bStack,customTesters,hasKey2),!result)return!1;return aStack.pop(),bStack.pop(),result}function keys(obj,hasKey2){let keys2=[];for(let key in obj)hasKey2(obj,key)&&keys2.push(key);return keys2.concat(Object.getOwnPropertySymbols(obj).filter(symbol=>Object.getOwnPropertyDescriptor(obj,symbol).enumerable))}function hasDefinedKey(obj,key){return hasKey(obj,key)&&obj[key]!==void 0}function hasKey(obj,key){return Object.prototype.hasOwnProperty.call(obj,key)}function isA(typeName,value){return Object.prototype.toString.apply(value)===`[object ${typeName}]`}function isDomNode(obj){return obj!==null&&typeof obj=="object"&&"nodeType"in obj&&typeof obj.nodeType=="number"&&"nodeName"in obj&&typeof obj.nodeName=="string"&&"isEqualNode"in obj&&typeof obj.isEqualNode=="function"}var IS_KEYED_SENTINEL="@@__IMMUTABLE_KEYED__@@",IS_SET_SENTINEL="@@__IMMUTABLE_SET__@@",IS_ORDERED_SENTINEL="@@__IMMUTABLE_ORDERED__@@";function isImmutableUnorderedKeyed(maybeKeyed){return!!(maybeKeyed&&maybeKeyed[IS_KEYED_SENTINEL]&&!maybeKeyed[IS_ORDERED_SENTINEL])}function isImmutableUnorderedSet(maybeSet){return!!(maybeSet&&maybeSet[IS_SET_SENTINEL]&&!maybeSet[IS_ORDERED_SENTINEL])}var IteratorSymbol=Symbol.iterator;function hasIterator(object){return!!(object!=null&&object[IteratorSymbol])}function iterableEquality(a,b2,aStack=[],bStack=[]){if(typeof a!="object"||typeof b2!="object"||Array.isArray(a)||Array.isArray(b2)||!hasIterator(a)||!hasIterator(b2))return;if(a.constructor!==b2.constructor)return!1;let length=aStack.length;for(;length--;)if(aStack[length]===a)return bStack[length]===b2;aStack.push(a),bStack.push(b2);let iterableEqualityWithStack=(a2,b22)=>iterableEquality(a2,b22,[...aStack],[...bStack]);if(a.size!==void 0){if(a.size!==b2.size)return!1;if(isA("Set",a)||isImmutableUnorderedSet(a)){let allFound=!0;for(let aValue of a)if(!b2.has(aValue)){let has=!1;for(let bValue of b2)equals(aValue,bValue,[iterableEqualityWithStack])===!0&&(has=!0);if(has===!1){allFound=!1;break}}return aStack.pop(),bStack.pop(),allFound}else if(isA("Map",a)||isImmutableUnorderedKeyed(a)){let allFound=!0;for(let aEntry of a)if(!b2.has(aEntry[0])||!equals(aEntry[1],b2.get(aEntry[0]),[iterableEqualityWithStack])){let has=!1;for(let bEntry of b2){let matchedKey=equals(aEntry[0],bEntry[0],[iterableEqualityWithStack]),matchedValue=!1;matchedKey===!0&&(matchedValue=equals(aEntry[1],bEntry[1],[iterableEqualityWithStack])),matchedValue===!0&&(has=!0)}if(has===!1){allFound=!1;break}}return aStack.pop(),bStack.pop(),allFound}}let bIterator=b2[IteratorSymbol]();for(let aValue of a){let nextB=bIterator.next();if(nextB.done||!equals(aValue,nextB.value,[iterableEqualityWithStack]))return!1}return bIterator.next().done?(aStack.pop(),bStack.pop(),!0):!1}function hasPropertyInObject(object,key){return!object||typeof object!="object"||object===Object.prototype?!1:Object.prototype.hasOwnProperty.call(object,key)||hasPropertyInObject(Object.getPrototypeOf(object),key)}function isObjectWithKeys(a){return isObject(a)&&!(a instanceof Error)&&!Array.isArray(a)&&!(a instanceof Date)}function subsetEquality(object,subset){let subsetEqualityWithContext=(seenReferences=new WeakMap)=>(object2,subset2)=>{if(isObjectWithKeys(subset2))return Object.keys(subset2).every(key=>{if(isObjectWithKeys(subset2[key])){if(seenReferences.has(subset2[key]))return equals(object2[key],subset2[key],[iterableEquality]);seenReferences.set(subset2[key],!0)}let result=object2!=null&&hasPropertyInObject(object2,key)&&equals(object2[key],subset2[key],[iterableEquality,subsetEqualityWithContext(seenReferences)]);return seenReferences.delete(subset2[key]),result})};return subsetEqualityWithContext()(object,subset)}function typeEquality(a,b2){if(!(a==null||b2==null||a.constructor===b2.constructor))return!1}function arrayBufferEquality(a,b2){let dataViewA=a,dataViewB=b2;if(!(a instanceof DataView&&b2 instanceof DataView)){if(!(a instanceof ArrayBuffer)||!(b2 instanceof ArrayBuffer))return;dataViewA=new DataView(a),dataViewB=new DataView(b2)}if(dataViewA.byteLength!==dataViewB.byteLength)return!1;for(let i2=0;i2<dataViewA.byteLength;i2++)if(dataViewA.getUint8(i2)!==dataViewB.getUint8(i2))return!1;return!0}function sparseArrayEquality(a,b2){if(!Array.isArray(a)||!Array.isArray(b2))return;let aKeys=Object.keys(a),bKeys=Object.keys(b2);return equals(a,b2,[iterableEquality,typeEquality],!0)&&equals(aKeys,bKeys)}function generateToBeMessage(deepEqualityName,expected="#{this}",actual="#{exp}"){let toBeMessage=`expected ${expected} to be ${actual} // Object.is equality`;return["toStrictEqual","toEqual"].includes(deepEqualityName)?`${toBeMessage}
|
|
24
|
+
`),options)}}function isMockFunction2(fn2){return typeof fn2=="function"&&"_isMockFunction"in fn2&&fn2._isMockFunction}var import_pretty_format4=__toESM(require_build(),1),import_diff_sequences=__toESM(require_build2(),1);var import_loupe3=require("loupe"),IS_RECORD_SYMBOL="@@__IMMUTABLE_RECORD__@@",IS_COLLECTION_SYMBOL="@@__IMMUTABLE_ITERABLE__@@";function isImmutable(v){return v&&(v[IS_COLLECTION_SYMBOL]||v[IS_RECORD_SYMBOL])}var OBJECT_PROTO=Object.getPrototypeOf({});function getUnserializableMessage(err){return err instanceof Error?`<unserializable>: ${err.message}`:typeof err=="string"?`<unserializable>: ${err}`:"<unserializable>"}function serializeError(val,seen=new WeakMap){if(!val||typeof val=="string")return val;if(typeof val=="function")return`Function<${val.name||"anonymous"}>`;if(typeof val=="symbol")return val.toString();if(typeof val!="object")return val;if(isImmutable(val))return serializeError(val.toJSON(),seen);if(val instanceof Promise||val.constructor&&val.constructor.prototype==="AsyncFunction")return"Promise";if(typeof Element<"u"&&val instanceof Element)return val.tagName;if(typeof val.asymmetricMatch=="function")return`${val.toString()} ${format(val.sample)}`;if(seen.has(val))return seen.get(val);if(Array.isArray(val)){let clone2=new Array(val.length);return seen.set(val,clone2),val.forEach((e,i2)=>{try{clone2[i2]=serializeError(e,seen)}catch(err){clone2[i2]=getUnserializableMessage(err)}}),clone2}else{let clone2=Object.create(null);seen.set(val,clone2);let obj=val;for(;obj&&obj!==OBJECT_PROTO;)Object.getOwnPropertyNames(obj).forEach(key=>{if(!(key in clone2))try{clone2[key]=serializeError(val[key],seen)}catch(err){delete clone2[key],clone2[key]=getUnserializableMessage(err)}}),obj=Object.getPrototypeOf(obj);return clone2}}function normalizeErrorMessage(message){return message.replace(/__vite_ssr_import_\d+__\./g,"")}function processError(err,diffOptions){if(!err||typeof err!="object")return{message:err};if(err.stack&&(err.stackStr=String(err.stack)),err.name&&(err.nameStr=String(err.name)),err.showDiff||err.showDiff===void 0&&err.expected!==void 0&&err.actual!==void 0){let clonedActual=deepClone(err.actual,{forceWritable:!0}),clonedExpected=deepClone(err.expected,{forceWritable:!0}),{replacedActual,replacedExpected}=replaceAsymmetricMatcher(clonedActual,clonedExpected);err.diff=diff(replacedExpected,replacedActual,diffOptions)}typeof err.expected!="string"&&(err.expected=stringify(err.expected,10)),typeof err.actual!="string"&&(err.actual=stringify(err.actual,10));try{typeof err.message=="string"&&(err.message=normalizeErrorMessage(err.message)),typeof err.cause=="object"&&typeof err.cause.message=="string"&&(err.cause.message=normalizeErrorMessage(err.cause.message))}catch{}try{return serializeError(err)}catch(e){return serializeError(new Error(`Failed to fully serialize error: ${e==null?void 0:e.message}
|
|
25
|
+
Inner error message: ${err==null?void 0:err.message}`))}}function isAsymmetricMatcher(data){return getType(data)==="Object"&&typeof data.asymmetricMatch=="function"}function isReplaceable(obj1,obj2){let obj1Type=getType(obj1),obj2Type=getType(obj2);return obj1Type===obj2Type&&obj1Type==="Object"}function replaceAsymmetricMatcher(actual,expected,actualReplaced=new WeakSet,expectedReplaced=new WeakSet){return isReplaceable(actual,expected)?actualReplaced.has(actual)||expectedReplaced.has(expected)?{replacedActual:actual,replacedExpected:expected}:(actualReplaced.add(actual),expectedReplaced.add(expected),getOwnProperties(expected).forEach(key=>{let expectedValue=expected[key],actualValue=actual[key];if(isAsymmetricMatcher(expectedValue))expectedValue.asymmetricMatch(actualValue)&&(actual[key]=expectedValue);else if(isAsymmetricMatcher(actualValue))actualValue.asymmetricMatch(expectedValue)&&(expected[key]=actualValue);else if(isReplaceable(actualValue,expectedValue)){let replaced=replaceAsymmetricMatcher(actualValue,expectedValue,actualReplaced,expectedReplaced);actual[key]=replaced.replacedActual,expected[key]=replaced.replacedExpected}}),{replacedActual:actual,replacedExpected:expected}):{replacedActual:actual,replacedExpected:expected}}var import_chai=require("chai"),MATCHERS_OBJECT=Symbol.for("matchers-object"),JEST_MATCHERS_OBJECT=Symbol.for("$$jest-matchers-object-storybook"),GLOBAL_EXPECT=Symbol.for("expect-global");if(!Object.prototype.hasOwnProperty.call(globalThis,MATCHERS_OBJECT)){let globalState=new WeakMap;Object.defineProperty(globalThis,MATCHERS_OBJECT,{get:()=>globalState})}if(!Object.prototype.hasOwnProperty.call(globalThis,JEST_MATCHERS_OBJECT)){let matchers2=Object.create(null);Object.defineProperty(globalThis,JEST_MATCHERS_OBJECT,{configurable:!0,get:()=>({state:globalThis[MATCHERS_OBJECT].get(globalThis[GLOBAL_EXPECT]),matchers:matchers2})})}function getState(expect4){return globalThis[MATCHERS_OBJECT].get(expect4)}function setState(state,expect4){let map=globalThis[MATCHERS_OBJECT],current=map.get(expect4)||{};Object.assign(current,state),map.set(expect4,current)}function getMatcherUtils(){let c=()=>getColors(),EXPECTED_COLOR=c().green,RECEIVED_COLOR=c().red,INVERTED_COLOR=c().inverse,BOLD_WEIGHT=c().bold,DIM_COLOR=c().dim;function matcherHint(matcherName,received="received",expected="expected",options={}){let{comment="",isDirectExpectCall=!1,isNot=!1,promise="",secondArgument="",expectedColor=EXPECTED_COLOR,receivedColor=RECEIVED_COLOR,secondArgumentColor=EXPECTED_COLOR}=options,hint="",dimString="expect";return!isDirectExpectCall&&received!==""&&(hint+=DIM_COLOR(`${dimString}(`)+receivedColor(received),dimString=")"),promise!==""&&(hint+=DIM_COLOR(`${dimString}.`)+promise,dimString=""),isNot&&(hint+=`${DIM_COLOR(`${dimString}.`)}not`,dimString=""),matcherName.includes(".")?dimString+=matcherName:(hint+=DIM_COLOR(`${dimString}.`)+matcherName,dimString=""),expected===""?dimString+="()":(hint+=DIM_COLOR(`${dimString}(`)+expectedColor(expected),secondArgument&&(hint+=DIM_COLOR(", ")+secondArgumentColor(secondArgument)),dimString=")"),comment!==""&&(dimString+=` // ${comment}`),dimString!==""&&(hint+=DIM_COLOR(dimString)),hint}let SPACE_SYMBOL="\xB7",replaceTrailingSpaces=text=>text.replace(/\s+$/gm,spaces=>SPACE_SYMBOL.repeat(spaces.length));return{EXPECTED_COLOR,RECEIVED_COLOR,INVERTED_COLOR,BOLD_WEIGHT,DIM_COLOR,matcherHint,printReceived:object=>RECEIVED_COLOR(replaceTrailingSpaces(stringify(object))),printExpected:value=>EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)))}}function equals(a,b2,customTesters,strictCheck){return customTesters=customTesters||[],eq(a,b2,[],[],customTesters,strictCheck?hasKey:hasDefinedKey)}var functionToString=Function.prototype.toString;function isAsymmetric(obj){return!!obj&&typeof obj=="object"&&"asymmetricMatch"in obj&&isA("Function",obj.asymmetricMatch)}function asymmetricMatch(a,b2){let asymmetricA=isAsymmetric(a),asymmetricB=isAsymmetric(b2);if(!(asymmetricA&&asymmetricB)){if(asymmetricA)return a.asymmetricMatch(b2);if(asymmetricB)return b2.asymmetricMatch(a)}}function eq(a,b2,aStack,bStack,customTesters,hasKey2){let result=!0,asymmetricResult=asymmetricMatch(a,b2);if(asymmetricResult!==void 0)return asymmetricResult;for(let i2=0;i2<customTesters.length;i2++){let customTesterResult=customTesters[i2](a,b2);if(customTesterResult!==void 0)return customTesterResult}if(a instanceof Error&&b2 instanceof Error)return a.message===b2.message;if(Object.is(a,b2))return!0;if(a===null||b2===null)return a===b2;let className=Object.prototype.toString.call(a);if(className!==Object.prototype.toString.call(b2))return!1;switch(className){case"[object Boolean]":case"[object String]":case"[object Number]":return typeof a!=typeof b2?!1:typeof a!="object"&&typeof b2!="object"?Object.is(a,b2):Object.is(a.valueOf(),b2.valueOf());case"[object Date]":{let numA=+a,numB=+b2;return numA===numB||Number.isNaN(numA)&&Number.isNaN(numB)}case"[object RegExp]":return a.source===b2.source&&a.flags===b2.flags}if(typeof a!="object"||typeof b2!="object")return!1;if(isDomNode(a)&&isDomNode(b2))return a.isEqualNode(b2);let length=aStack.length;for(;length--;){if(aStack[length]===a)return bStack[length]===b2;if(bStack[length]===b2)return!1}if(aStack.push(a),bStack.push(b2),className==="[object Array]"&&a.length!==b2.length)return!1;let aKeys=keys(a,hasKey2),key,size=aKeys.length;if(keys(b2,hasKey2).length!==size)return!1;for(;size--;)if(key=aKeys[size],result=hasKey2(b2,key)&&eq(a[key],b2[key],aStack,bStack,customTesters,hasKey2),!result)return!1;return aStack.pop(),bStack.pop(),result}function keys(obj,hasKey2){let keys2=[];for(let key in obj)hasKey2(obj,key)&&keys2.push(key);return keys2.concat(Object.getOwnPropertySymbols(obj).filter(symbol=>Object.getOwnPropertyDescriptor(obj,symbol).enumerable))}function hasDefinedKey(obj,key){return hasKey(obj,key)&&obj[key]!==void 0}function hasKey(obj,key){return Object.prototype.hasOwnProperty.call(obj,key)}function isA(typeName,value){return Object.prototype.toString.apply(value)===`[object ${typeName}]`}function isDomNode(obj){return obj!==null&&typeof obj=="object"&&"nodeType"in obj&&typeof obj.nodeType=="number"&&"nodeName"in obj&&typeof obj.nodeName=="string"&&"isEqualNode"in obj&&typeof obj.isEqualNode=="function"}var IS_KEYED_SENTINEL="@@__IMMUTABLE_KEYED__@@",IS_SET_SENTINEL="@@__IMMUTABLE_SET__@@",IS_ORDERED_SENTINEL="@@__IMMUTABLE_ORDERED__@@";function isImmutableUnorderedKeyed(maybeKeyed){return!!(maybeKeyed&&maybeKeyed[IS_KEYED_SENTINEL]&&!maybeKeyed[IS_ORDERED_SENTINEL])}function isImmutableUnorderedSet(maybeSet){return!!(maybeSet&&maybeSet[IS_SET_SENTINEL]&&!maybeSet[IS_ORDERED_SENTINEL])}var IteratorSymbol=Symbol.iterator;function hasIterator(object){return!!(object!=null&&object[IteratorSymbol])}function iterableEquality(a,b2,aStack=[],bStack=[]){if(typeof a!="object"||typeof b2!="object"||Array.isArray(a)||Array.isArray(b2)||!hasIterator(a)||!hasIterator(b2))return;if(a.constructor!==b2.constructor)return!1;let length=aStack.length;for(;length--;)if(aStack[length]===a)return bStack[length]===b2;aStack.push(a),bStack.push(b2);let iterableEqualityWithStack=(a2,b22)=>iterableEquality(a2,b22,[...aStack],[...bStack]);if(a.size!==void 0){if(a.size!==b2.size)return!1;if(isA("Set",a)||isImmutableUnorderedSet(a)){let allFound=!0;for(let aValue of a)if(!b2.has(aValue)){let has=!1;for(let bValue of b2)equals(aValue,bValue,[iterableEqualityWithStack])===!0&&(has=!0);if(has===!1){allFound=!1;break}}return aStack.pop(),bStack.pop(),allFound}else if(isA("Map",a)||isImmutableUnorderedKeyed(a)){let allFound=!0;for(let aEntry of a)if(!b2.has(aEntry[0])||!equals(aEntry[1],b2.get(aEntry[0]),[iterableEqualityWithStack])){let has=!1;for(let bEntry of b2){let matchedKey=equals(aEntry[0],bEntry[0],[iterableEqualityWithStack]),matchedValue=!1;matchedKey===!0&&(matchedValue=equals(aEntry[1],bEntry[1],[iterableEqualityWithStack])),matchedValue===!0&&(has=!0)}if(has===!1){allFound=!1;break}}return aStack.pop(),bStack.pop(),allFound}}let bIterator=b2[IteratorSymbol]();for(let aValue of a){let nextB=bIterator.next();if(nextB.done||!equals(aValue,nextB.value,[iterableEqualityWithStack]))return!1}return bIterator.next().done?(aStack.pop(),bStack.pop(),!0):!1}function hasPropertyInObject(object,key){return!object||typeof object!="object"||object===Object.prototype?!1:Object.prototype.hasOwnProperty.call(object,key)||hasPropertyInObject(Object.getPrototypeOf(object),key)}function isObjectWithKeys(a){return isObject(a)&&!(a instanceof Error)&&!Array.isArray(a)&&!(a instanceof Date)}function subsetEquality(object,subset){let subsetEqualityWithContext=(seenReferences=new WeakMap)=>(object2,subset2)=>{if(isObjectWithKeys(subset2))return Object.keys(subset2).every(key=>{if(isObjectWithKeys(subset2[key])){if(seenReferences.has(subset2[key]))return equals(object2[key],subset2[key],[iterableEquality]);seenReferences.set(subset2[key],!0)}let result=object2!=null&&hasPropertyInObject(object2,key)&&equals(object2[key],subset2[key],[iterableEquality,subsetEqualityWithContext(seenReferences)]);return seenReferences.delete(subset2[key]),result})};return subsetEqualityWithContext()(object,subset)}function typeEquality(a,b2){if(!(a==null||b2==null||a.constructor===b2.constructor))return!1}function arrayBufferEquality(a,b2){let dataViewA=a,dataViewB=b2;if(!(a instanceof DataView&&b2 instanceof DataView)){if(!(a instanceof ArrayBuffer)||!(b2 instanceof ArrayBuffer))return;try{dataViewA=new DataView(a),dataViewB=new DataView(b2)}catch{return}}if(dataViewA.byteLength!==dataViewB.byteLength)return!1;for(let i2=0;i2<dataViewA.byteLength;i2++)if(dataViewA.getUint8(i2)!==dataViewB.getUint8(i2))return!1;return!0}function sparseArrayEquality(a,b2){if(!Array.isArray(a)||!Array.isArray(b2))return;let aKeys=Object.keys(a),bKeys=Object.keys(b2);return equals(a,b2,[iterableEquality,typeEquality],!0)&&equals(aKeys,bKeys)}function generateToBeMessage(deepEqualityName,expected="#{this}",actual="#{exp}"){let toBeMessage=`expected ${expected} to be ${actual} // Object.is equality`;return["toStrictEqual","toEqual"].includes(deepEqualityName)?`${toBeMessage}
|
|
26
26
|
|
|
27
27
|
If it should pass with deep equality, replace "toBe" with "${deepEqualityName}"
|
|
28
28
|
|
|
29
29
|
Expected: ${expected}
|
|
30
30
|
Received: serializes to the same string
|
|
31
|
-
`:toBeMessage}var AsymmetricMatcher3=class{constructor(sample,inverse=!1){this.sample=sample,this.inverse=inverse}$$typeof=Symbol.for("jest.asymmetricMatcher");getMatcherContext(expect4){return{...getState(expect4||globalThis[GLOBAL_EXPECT]),equals,isNot:this.inverse,utils:{...getMatcherUtils(),diff,stringify,iterableEquality,subsetEquality}}}},StringContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){if(!isA("String",sample))throw new Error("Expected is not a string");super(sample,inverse)}asymmetricMatch(other){let result=isA("String",other)&&other.includes(this.sample);return this.inverse?!result:result}toString(){return`String${this.inverse?"Not":""}Containing`}getExpectedType(){return"string"}},Anything=class extends AsymmetricMatcher3{asymmetricMatch(other){return other!=null}toString(){return"Anything"}toAsymmetricMatcher(){return"Anything"}},ObjectContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){super(sample,inverse)}getPrototype(obj){return Object.getPrototypeOf?Object.getPrototypeOf(obj):obj.constructor.prototype===obj?null:obj.constructor.prototype}hasProperty(obj,property){return obj?Object.prototype.hasOwnProperty.call(obj,property)?!0:this.hasProperty(this.getPrototype(obj),property):!1}asymmetricMatch(other){if(typeof this.sample!="object")throw new TypeError(`You must provide an object to ${this.toString()}, not '${typeof this.sample}'.`);let result=!0;for(let property in this.sample)if(!this.hasProperty(other,property)||!equals(this.sample[property],other[property])){result=!1;break}return this.inverse?!result:result}toString(){return`Object${this.inverse?"Not":""}Containing`}getExpectedType(){return"object"}},ArrayContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){super(sample,inverse)}asymmetricMatch(other){if(!Array.isArray(this.sample))throw new TypeError(`You must provide an array to ${this.toString()}, not '${typeof this.sample}'.`);let result=this.sample.length===0||Array.isArray(other)&&this.sample.every(item=>other.some(another=>equals(item,another)));return this.inverse?!result:result}toString(){return`Array${this.inverse?"Not":""}Containing`}getExpectedType(){return"array"}},Any=class extends AsymmetricMatcher3{constructor(sample){if(typeof sample>"u")throw new TypeError("any() expects to be passed a constructor function. Please pass one or use anything() to match any object.");super(sample)}fnNameFor(func){if(func.name)return func.name;let matches=Function.prototype.toString.call(func).match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/);return matches?matches[1]:"<anonymous>"}asymmetricMatch(other){return this.sample===String?typeof other=="string"||other instanceof String:this.sample===Number?typeof other=="number"||other instanceof Number:this.sample===Function?typeof other=="function"||other instanceof Function:this.sample===Boolean?typeof other=="boolean"||other instanceof Boolean:this.sample===BigInt?typeof other=="bigint"||other instanceof BigInt:this.sample===Symbol?typeof other=="symbol"||other instanceof Symbol:this.sample===Object?typeof other=="object":other instanceof this.sample}toString(){return"Any"}getExpectedType(){return this.sample===String?"string":this.sample===Number?"number":this.sample===Function?"function":this.sample===Object?"object":this.sample===Boolean?"boolean":this.fnNameFor(this.sample)}toAsymmetricMatcher(){return`Any<${this.fnNameFor(this.sample)}>`}},StringMatching=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){if(!isA("String",sample)&&!isA("RegExp",sample))throw new Error("Expected is not a String or a RegExp");super(new RegExp(sample),inverse)}asymmetricMatch(other){let result=isA("String",other)&&this.sample.test(other);return this.inverse?!result:result}toString(){return`String${this.inverse?"Not":""}Matching`}getExpectedType(){return"string"}},JestAsymmetricMatchers=(chai3,utils)=>{utils.addMethod(chai3.expect,"anything",()=>new Anything),utils.addMethod(chai3.expect,"any",expected=>new Any(expected)),utils.addMethod(chai3.expect,"stringContaining",expected=>new StringContaining(expected)),utils.addMethod(chai3.expect,"objectContaining",expected=>new ObjectContaining(expected)),utils.addMethod(chai3.expect,"arrayContaining",expected=>new ArrayContaining(expected)),utils.addMethod(chai3.expect,"stringMatching",expected=>new StringMatching(expected)),chai3.expect.not={stringContaining:expected=>new StringContaining(expected,!0),objectContaining:expected=>new ObjectContaining(expected,!0),arrayContaining:expected=>new ArrayContaining(expected,!0),stringMatching:expected=>new StringMatching(expected,!0)}};function recordAsyncExpect(test,promise){return test&&promise instanceof Promise&&(promise=promise.finally(()=>{let index=test.promises.indexOf(promise);index!==-1&&test.promises.splice(index,1)}),test.promises||(test.promises=[]),test.promises.push(promise)),promise}function wrapSoft(utils,fn2){return function(...args){var _a;let test=utils.flag(this,"vitest-test");if(!(test!=null&&test.context._local?test.context.expect.getState():getState(globalThis[GLOBAL_EXPECT])).soft)return fn2.apply(this,args);if(!test)throw new Error("expect.soft() can only be used inside a test");try{return fn2.apply(this,args)}catch(err){test.result||(test.result={state:"fail"}),test.result.state="fail",(_a=test.result).errors||(_a.errors=[]),test.result.errors.push(processError(err))}}}var JestChaiExpect=(chai3,utils)=>{let c=()=>getColors();function def(name,fn2){let addMethod=n=>{let softWrapper=wrapSoft(utils,fn2);utils.addMethod(chai3.Assertion.prototype,n,softWrapper),utils.addMethod(globalThis[JEST_MATCHERS_OBJECT].matchers,n,softWrapper)};Array.isArray(name)?name.forEach(n=>addMethod(n)):addMethod(name)}["throw","throws","Throw"].forEach(m2=>{utils.overwriteMethod(chai3.Assertion.prototype,m2,_super=>function(...args){let promise=utils.flag(this,"promise"),object=utils.flag(this,"object"),isNot=utils.flag(this,"negate");if(promise==="rejects")utils.flag(this,"object",()=>{throw object});else if(promise==="resolves"&&typeof object!="function"){if(isNot)return;{let message=utils.flag(this,"message")||"expected promise to throw an error, but it didn't",error={showDiff:!1};throw new import_chai.AssertionError(message,error,utils.flag(this,"ssfi"))}}_super.apply(this,args)})}),def("withTest",function(test){return utils.flag(this,"vitest-test",test),this}),def("toEqual",function(expected){let actual=utils.flag(this,"object"),equal=equals(actual,expected,[iterableEquality]);return this.assert(equal,"expected #{this} to deeply equal #{exp}","expected #{this} to not deeply equal #{exp}",expected,actual)}),def("toStrictEqual",function(expected){let obj=utils.flag(this,"object"),equal=equals(obj,expected,[iterableEquality,typeEquality,sparseArrayEquality,arrayBufferEquality],!0);return this.assert(equal,"expected #{this} to strictly equal #{exp}","expected #{this} to not strictly equal #{exp}",expected,obj)}),def("toBe",function(expected){let actual=this._obj,pass=Object.is(actual,expected),deepEqualityName="";return pass||(equals(actual,expected,[iterableEquality,typeEquality,sparseArrayEquality,arrayBufferEquality],!0)?deepEqualityName="toStrictEqual":equals(actual,expected,[iterableEquality])&&(deepEqualityName="toEqual")),this.assert(pass,generateToBeMessage(deepEqualityName),"expected #{this} not to be #{exp} // Object.is equality",expected,actual)}),def("toMatchObject",function(expected){let actual=this._obj;return this.assert(equals(actual,expected,[iterableEquality,subsetEquality]),"expected #{this} to match object #{exp}","expected #{this} to not match object #{exp}",expected,actual)}),def("toMatch",function(expected){return typeof expected=="string"?this.include(expected):this.match(expected)}),def("toContain",function(item){return this.contain(item)}),def("toContainEqual",function(expected){let obj=utils.flag(this,"object"),index=Array.from(obj).findIndex(item=>equals(item,expected));this.assert(index!==-1,"expected #{this} to deep equally contain #{exp}","expected #{this} to not deep equally contain #{exp}",expected)}),def("toBeTruthy",function(){let obj=utils.flag(this,"object");this.assert(!!obj,"expected #{this} to be truthy","expected #{this} to not be truthy",obj,!1)}),def("toBeFalsy",function(){let obj=utils.flag(this,"object");this.assert(!obj,"expected #{this} to be falsy","expected #{this} to not be falsy",obj,!1)}),def("toBeGreaterThan",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual>expected,`expected ${actual} to be greater than ${expected}`,`expected ${actual} to be not greater than ${expected}`,actual,expected,!1)}),def("toBeGreaterThanOrEqual",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual>=expected,`expected ${actual} to be greater than or equal to ${expected}`,`expected ${actual} to be not greater than or equal to ${expected}`,actual,expected,!1)}),def("toBeLessThan",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual<expected,`expected ${actual} to be less than ${expected}`,`expected ${actual} to be not less than ${expected}`,actual,expected,!1)}),def("toBeLessThanOrEqual",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual<=expected,`expected ${actual} to be less than or equal to ${expected}`,`expected ${actual} to be not less than or equal to ${expected}`,actual,expected,!1)}),def("toBeNaN",function(){return this.be.NaN}),def("toBeUndefined",function(){return this.be.undefined}),def("toBeNull",function(){return this.be.null}),def("toBeDefined",function(){let negate=utils.flag(this,"negate");return utils.flag(this,"negate",!1),negate?this.be.undefined:this.not.be.undefined}),def("toBeTypeOf",function(expected){let actual=typeof this._obj,equal=expected===actual;return this.assert(equal,"expected #{this} to be type of #{exp}","expected #{this} not to be type of #{exp}",expected,actual)}),def("toBeInstanceOf",function(obj){return this.instanceOf(obj)}),def("toHaveLength",function(length){return this.have.length(length)}),def("toHaveProperty",function(...args){Array.isArray(args[0])&&(args[0]=args[0].map(key=>String(key).replace(/([.[\]])/g,"\\$1")).join("."));let actual=this._obj,[propertyName,expected]=args,getValue=()=>Object.prototype.hasOwnProperty.call(actual,propertyName)?{value:actual[propertyName],exists:!0}:utils.getPathInfo(actual,propertyName),{value,exists}=getValue(),pass=exists&&(args.length===1||equals(expected,value)),valueString=args.length===1?"":` with value ${utils.objDisplay(expected)}`;return this.assert(pass,`expected #{this} to have property "${propertyName}"${valueString}`,`expected #{this} to not have property "${propertyName}"${valueString}`,actual)}),def("toBeCloseTo",function(received,precision=2){let expected=this._obj,pass=!1,expectedDiff=0,receivedDiff=0;return received===Number.POSITIVE_INFINITY&&expected===Number.POSITIVE_INFINITY||received===Number.NEGATIVE_INFINITY&&expected===Number.NEGATIVE_INFINITY?pass=!0:(expectedDiff=10**-precision/2,receivedDiff=Math.abs(expected-received),pass=receivedDiff<expectedDiff),this.assert(pass,`expected #{this} to be close to #{exp}, received difference is ${receivedDiff}, but expected ${expectedDiff}`,`expected #{this} to not be close to #{exp}, received difference is ${receivedDiff}, but expected ${expectedDiff}`,received,expected,!1)});let assertIsMock=assertion=>{if(!isMockFunction(assertion._obj))throw new TypeError(`${utils.inspect(assertion._obj)} is not a spy or a call to a spy!`)},getSpy=assertion=>(assertIsMock(assertion),assertion._obj),ordinalOf=i2=>{let j=i2%10,k=i2%100;return j===1&&k!==11?`${i2}st`:j===2&&k!==12?`${i2}nd`:j===3&&k!==13?`${i2}rd`:`${i2}th`},formatCalls=(spy,msg,actualCall)=>(spy.mock.calls&&(msg+=c().gray(`
|
|
31
|
+
`:toBeMessage}var AsymmetricMatcher3=class{constructor(sample,inverse=!1){this.sample=sample,this.inverse=inverse}$$typeof=Symbol.for("jest.asymmetricMatcher");getMatcherContext(expect4){return{...getState(expect4||globalThis[GLOBAL_EXPECT]),equals,isNot:this.inverse,utils:{...getMatcherUtils(),diff,stringify,iterableEquality,subsetEquality}}}},StringContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){if(!isA("String",sample))throw new Error("Expected is not a string");super(sample,inverse)}asymmetricMatch(other){let result=isA("String",other)&&other.includes(this.sample);return this.inverse?!result:result}toString(){return`String${this.inverse?"Not":""}Containing`}getExpectedType(){return"string"}},Anything=class extends AsymmetricMatcher3{asymmetricMatch(other){return other!=null}toString(){return"Anything"}toAsymmetricMatcher(){return"Anything"}},ObjectContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){super(sample,inverse)}getPrototype(obj){return Object.getPrototypeOf?Object.getPrototypeOf(obj):obj.constructor.prototype===obj?null:obj.constructor.prototype}hasProperty(obj,property){return obj?Object.prototype.hasOwnProperty.call(obj,property)?!0:this.hasProperty(this.getPrototype(obj),property):!1}asymmetricMatch(other){if(typeof this.sample!="object")throw new TypeError(`You must provide an object to ${this.toString()}, not '${typeof this.sample}'.`);let result=!0;for(let property in this.sample)if(!this.hasProperty(other,property)||!equals(this.sample[property],other[property])){result=!1;break}return this.inverse?!result:result}toString(){return`Object${this.inverse?"Not":""}Containing`}getExpectedType(){return"object"}},ArrayContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){super(sample,inverse)}asymmetricMatch(other){if(!Array.isArray(this.sample))throw new TypeError(`You must provide an array to ${this.toString()}, not '${typeof this.sample}'.`);let result=this.sample.length===0||Array.isArray(other)&&this.sample.every(item=>other.some(another=>equals(item,another)));return this.inverse?!result:result}toString(){return`Array${this.inverse?"Not":""}Containing`}getExpectedType(){return"array"}},Any=class extends AsymmetricMatcher3{constructor(sample){if(typeof sample>"u")throw new TypeError("any() expects to be passed a constructor function. Please pass one or use anything() to match any object.");super(sample)}fnNameFor(func){if(func.name)return func.name;let matches=Function.prototype.toString.call(func).match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/);return matches?matches[1]:"<anonymous>"}asymmetricMatch(other){return this.sample===String?typeof other=="string"||other instanceof String:this.sample===Number?typeof other=="number"||other instanceof Number:this.sample===Function?typeof other=="function"||other instanceof Function:this.sample===Boolean?typeof other=="boolean"||other instanceof Boolean:this.sample===BigInt?typeof other=="bigint"||other instanceof BigInt:this.sample===Symbol?typeof other=="symbol"||other instanceof Symbol:this.sample===Object?typeof other=="object":other instanceof this.sample}toString(){return"Any"}getExpectedType(){return this.sample===String?"string":this.sample===Number?"number":this.sample===Function?"function":this.sample===Object?"object":this.sample===Boolean?"boolean":this.fnNameFor(this.sample)}toAsymmetricMatcher(){return`Any<${this.fnNameFor(this.sample)}>`}},StringMatching=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){if(!isA("String",sample)&&!isA("RegExp",sample))throw new Error("Expected is not a String or a RegExp");super(new RegExp(sample),inverse)}asymmetricMatch(other){let result=isA("String",other)&&this.sample.test(other);return this.inverse?!result:result}toString(){return`String${this.inverse?"Not":""}Matching`}getExpectedType(){return"string"}},JestAsymmetricMatchers=(chai3,utils)=>{utils.addMethod(chai3.expect,"anything",()=>new Anything),utils.addMethod(chai3.expect,"any",expected=>new Any(expected)),utils.addMethod(chai3.expect,"stringContaining",expected=>new StringContaining(expected)),utils.addMethod(chai3.expect,"objectContaining",expected=>new ObjectContaining(expected)),utils.addMethod(chai3.expect,"arrayContaining",expected=>new ArrayContaining(expected)),utils.addMethod(chai3.expect,"stringMatching",expected=>new StringMatching(expected)),chai3.expect.not={stringContaining:expected=>new StringContaining(expected,!0),objectContaining:expected=>new ObjectContaining(expected,!0),arrayContaining:expected=>new ArrayContaining(expected,!0),stringMatching:expected=>new StringMatching(expected,!0)}};function recordAsyncExpect(test,promise){return test&&promise instanceof Promise&&(promise=promise.finally(()=>{let index=test.promises.indexOf(promise);index!==-1&&test.promises.splice(index,1)}),test.promises||(test.promises=[]),test.promises.push(promise)),promise}function wrapSoft(utils,fn2){return function(...args){var _a;let test=utils.flag(this,"vitest-test");if(!(test!=null&&test.context._local?test.context.expect.getState():getState(globalThis[GLOBAL_EXPECT])).soft)return fn2.apply(this,args);if(!test)throw new Error("expect.soft() can only be used inside a test");try{return fn2.apply(this,args)}catch(err){test.result||(test.result={state:"fail"}),test.result.state="fail",(_a=test.result).errors||(_a.errors=[]),test.result.errors.push(processError(err))}}}var JestChaiExpect=(chai3,utils)=>{let{AssertionError}=chai3,c=()=>getColors();function def(name,fn2){let addMethod=n=>{let softWrapper=wrapSoft(utils,fn2);utils.addMethod(chai3.Assertion.prototype,n,softWrapper),utils.addMethod(globalThis[JEST_MATCHERS_OBJECT].matchers,n,softWrapper)};Array.isArray(name)?name.forEach(n=>addMethod(n)):addMethod(name)}["throw","throws","Throw"].forEach(m2=>{utils.overwriteMethod(chai3.Assertion.prototype,m2,_super=>function(...args){let promise=utils.flag(this,"promise"),object=utils.flag(this,"object"),isNot=utils.flag(this,"negate");if(promise==="rejects")utils.flag(this,"object",()=>{throw object});else if(promise==="resolves"&&typeof object!="function"){if(isNot)return;{let message=utils.flag(this,"message")||"expected promise to throw an error, but it didn't",error={showDiff:!1};throw new AssertionError(message,error,utils.flag(this,"ssfi"))}}_super.apply(this,args)})}),def("withTest",function(test){return utils.flag(this,"vitest-test",test),this}),def("toEqual",function(expected){let actual=utils.flag(this,"object"),equal=equals(actual,expected,[iterableEquality]);return this.assert(equal,"expected #{this} to deeply equal #{exp}","expected #{this} to not deeply equal #{exp}",expected,actual)}),def("toStrictEqual",function(expected){let obj=utils.flag(this,"object"),equal=equals(obj,expected,[iterableEquality,typeEquality,sparseArrayEquality,arrayBufferEquality],!0);return this.assert(equal,"expected #{this} to strictly equal #{exp}","expected #{this} to not strictly equal #{exp}",expected,obj)}),def("toBe",function(expected){let actual=this._obj,pass=Object.is(actual,expected),deepEqualityName="";return pass||(equals(actual,expected,[iterableEquality,typeEquality,sparseArrayEquality,arrayBufferEquality],!0)?deepEqualityName="toStrictEqual":equals(actual,expected,[iterableEquality])&&(deepEqualityName="toEqual")),this.assert(pass,generateToBeMessage(deepEqualityName),"expected #{this} not to be #{exp} // Object.is equality",expected,actual)}),def("toMatchObject",function(expected){let actual=this._obj;return this.assert(equals(actual,expected,[iterableEquality,subsetEquality]),"expected #{this} to match object #{exp}","expected #{this} to not match object #{exp}",expected,actual)}),def("toMatch",function(expected){return typeof expected=="string"?this.include(expected):this.match(expected)}),def("toContain",function(item){return this.contain(item)}),def("toContainEqual",function(expected){let obj=utils.flag(this,"object"),index=Array.from(obj).findIndex(item=>equals(item,expected));this.assert(index!==-1,"expected #{this} to deep equally contain #{exp}","expected #{this} to not deep equally contain #{exp}",expected)}),def("toBeTruthy",function(){let obj=utils.flag(this,"object");this.assert(!!obj,"expected #{this} to be truthy","expected #{this} to not be truthy",obj,!1)}),def("toBeFalsy",function(){let obj=utils.flag(this,"object");this.assert(!obj,"expected #{this} to be falsy","expected #{this} to not be falsy",obj,!1)}),def("toBeGreaterThan",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual>expected,`expected ${actual} to be greater than ${expected}`,`expected ${actual} to be not greater than ${expected}`,actual,expected,!1)}),def("toBeGreaterThanOrEqual",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual>=expected,`expected ${actual} to be greater than or equal to ${expected}`,`expected ${actual} to be not greater than or equal to ${expected}`,actual,expected,!1)}),def("toBeLessThan",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual<expected,`expected ${actual} to be less than ${expected}`,`expected ${actual} to be not less than ${expected}`,actual,expected,!1)}),def("toBeLessThanOrEqual",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual<=expected,`expected ${actual} to be less than or equal to ${expected}`,`expected ${actual} to be not less than or equal to ${expected}`,actual,expected,!1)}),def("toBeNaN",function(){return this.be.NaN}),def("toBeUndefined",function(){return this.be.undefined}),def("toBeNull",function(){return this.be.null}),def("toBeDefined",function(){let negate=utils.flag(this,"negate");return utils.flag(this,"negate",!1),negate?this.be.undefined:this.not.be.undefined}),def("toBeTypeOf",function(expected){let actual=typeof this._obj,equal=expected===actual;return this.assert(equal,"expected #{this} to be type of #{exp}","expected #{this} not to be type of #{exp}",expected,actual)}),def("toBeInstanceOf",function(obj){return this.instanceOf(obj)}),def("toHaveLength",function(length){return this.have.length(length)}),def("toHaveProperty",function(...args){Array.isArray(args[0])&&(args[0]=args[0].map(key=>String(key).replace(/([.[\]])/g,"\\$1")).join("."));let actual=this._obj,[propertyName,expected]=args,getValue=()=>Object.prototype.hasOwnProperty.call(actual,propertyName)?{value:actual[propertyName],exists:!0}:utils.getPathInfo(actual,propertyName),{value,exists}=getValue(),pass=exists&&(args.length===1||equals(expected,value)),valueString=args.length===1?"":` with value ${utils.objDisplay(expected)}`;return this.assert(pass,`expected #{this} to have property "${propertyName}"${valueString}`,`expected #{this} to not have property "${propertyName}"${valueString}`,actual)}),def("toBeCloseTo",function(received,precision=2){let expected=this._obj,pass=!1,expectedDiff=0,receivedDiff=0;return received===Number.POSITIVE_INFINITY&&expected===Number.POSITIVE_INFINITY||received===Number.NEGATIVE_INFINITY&&expected===Number.NEGATIVE_INFINITY?pass=!0:(expectedDiff=10**-precision/2,receivedDiff=Math.abs(expected-received),pass=receivedDiff<expectedDiff),this.assert(pass,`expected #{this} to be close to #{exp}, received difference is ${receivedDiff}, but expected ${expectedDiff}`,`expected #{this} to not be close to #{exp}, received difference is ${receivedDiff}, but expected ${expectedDiff}`,received,expected,!1)});let assertIsMock=assertion=>{if(!isMockFunction2(assertion._obj))throw new TypeError(`${utils.inspect(assertion._obj)} is not a spy or a call to a spy!`)},getSpy=assertion=>(assertIsMock(assertion),assertion._obj),ordinalOf=i2=>{let j=i2%10,k=i2%100;return j===1&&k!==11?`${i2}st`:j===2&&k!==12?`${i2}nd`:j===3&&k!==13?`${i2}rd`:`${i2}th`},formatCalls=(spy,msg,actualCall)=>(spy.mock.calls&&(msg+=c().gray(`
|
|
32
32
|
|
|
33
33
|
Received:
|
|
34
34
|
|
|
@@ -54,7 +54,7 @@ ${spy.mock.results.map((callReturn,i2)=>{let methodCall=c().bold(` ${ordinalOf(
|
|
|
54
54
|
`)}`),msg+=c().gray(`
|
|
55
55
|
|
|
56
56
|
Number of calls: ${c().bold(spy.mock.calls.length)}
|
|
57
|
-
`),msg);def(["toHaveBeenCalledTimes","toBeCalledTimes"],function(number){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length;return this.assert(callCount===number,`expected "${spyName}" to be called #{exp} times, but got ${callCount} times`,`expected "${spyName}" to not be called #{exp} times`,number,callCount,!1)}),def("toHaveBeenCalledOnce",function(){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length;return this.assert(callCount===1,`expected "${spyName}" to be called once, but got ${callCount} times`,`expected "${spyName}" to not be called once`,1,callCount,!1)}),def(["toHaveBeenCalled","toBeCalled"],function(){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length,called=callCount>0,isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[called,`expected "${spyName}" to be called at least once`,`expected "${spyName}" to not be called at all, but actually been called ${callCount} times`,!0,called]);if(called&&isNot&&(msg=formatCalls(spy,msg)),called&&isNot||!called&&!isNot){let err=new Error(msg);throw err.name="AssertionError",err}}),def(["toHaveBeenCalledWith","toBeCalledWith"],function(...args){let spy=getSpy(this),spyName=spy.getMockName(),pass=spy.mock.calls.some(callArg=>equals(callArg,args,[iterableEquality])),isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[pass,`expected "${spyName}" to be called with arguments: #{exp}`,`expected "${spyName}" to not be called with arguments: #{exp}`,args]);if(pass&&isNot||!pass&&!isNot){msg=formatCalls(spy,msg,args);let err=new Error(msg);throw err.name="AssertionError",err}}),def(["toHaveBeenNthCalledWith","nthCalledWith"],function(times,...args){let spy=getSpy(this),spyName=spy.getMockName(),nthCall=spy.mock.calls[times-1];this.assert(equals(nthCall,args,[iterableEquality]),`expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}`,`expected ${ordinalOf(times)} "${spyName}" call to not have been called with #{exp}`,args,nthCall)}),def(["toHaveBeenLastCalledWith","lastCalledWith"],function(...args){let spy=getSpy(this),spyName=spy.getMockName(),lastCall=spy.mock.calls[spy.mock.calls.length-1];this.assert(equals(lastCall,args,[iterableEquality]),`expected last "${spyName}" call to have been called with #{exp}`,`expected last "${spyName}" call to not have been called with #{exp}`,args,lastCall)}),def(["toThrow","toThrowError"],function(expected){if(typeof expected=="string"||typeof expected>"u"||expected instanceof RegExp)return this.throws(expected);let obj=this._obj,promise=utils.flag(this,"promise"),isNot=utils.flag(this,"negate"),thrown=null;if(promise==="rejects")thrown=obj;else if(promise==="resolves"&&typeof obj!="function"){if(isNot)return;{let message=utils.flag(this,"message")||"expected promise to throw an error, but it didn't",error={showDiff:!1};throw new import_chai.AssertionError(message,error,utils.flag(this,"ssfi"))}}else try{obj()}catch(err){thrown=err}if(typeof expected=="function"){let name=expected.name||expected.prototype.constructor.name;return this.assert(thrown&&thrown instanceof expected,`expected error to be instance of ${name}`,`expected error not to be instance of ${name}`,expected,thrown,!1)}if(expected instanceof Error)return this.assert(thrown&&expected.message===thrown.message,`expected error to have message: ${expected.message}`,`expected error not to have message: ${expected.message}`,expected.message,thrown&&thrown.message);if(typeof expected=="object"&&"asymmetricMatch"in expected&&typeof expected.asymmetricMatch=="function"){let matcher=expected;return this.assert(thrown&&matcher.asymmetricMatch(thrown),"expected error to match asymmetric matcher","expected error not to match asymmetric matcher",matcher.toString(),thrown,!1)}throw new Error(`"toThrow" expects string, RegExp, function, Error instance or asymmetric matcher, got "${typeof expected}"`)}),def(["toHaveReturned","toReturn"],function(){let spy=getSpy(this),spyName=spy.getMockName(),calledAndNotThrew=spy.mock.calls.length>0&&spy.mock.results.some(({type})=>type!=="throw");this.assert(calledAndNotThrew,`expected "${spyName}" to be successfully called at least once`,`expected "${spyName}" to not be successfully called`,calledAndNotThrew,!calledAndNotThrew,!1)}),def(["toHaveReturnedTimes","toReturnTimes"],function(times){let spy=getSpy(this),spyName=spy.getMockName(),successfulReturns=spy.mock.results.reduce((success,{type})=>type==="throw"?success:++success,0);this.assert(successfulReturns===times,`expected "${spyName}" to be successfully called ${times} times`,`expected "${spyName}" to not be successfully called ${times} times`,`expected number of returns: ${times}`,`received number of returns: ${successfulReturns}`,!1)}),def(["toHaveReturnedWith","toReturnWith"],function(value){let spy=getSpy(this),spyName=spy.getMockName(),pass=spy.mock.results.some(({type,value:result})=>type==="return"&&equals(value,result)),isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[pass,`expected "${spyName}" to return with: #{exp} at least once`,`expected "${spyName}" to not return with: #{exp}`,value]);if(pass&&isNot||!pass&&!isNot){msg=formatReturns(spy,msg,value);let err=new Error(msg);throw err.name="AssertionError",err}}),def(["toHaveLastReturnedWith","lastReturnedWith"],function(value){let spy=getSpy(this),spyName=spy.getMockName(),{value:lastResult}=spy.mock.results[spy.mock.results.length-1],pass=equals(lastResult,value);this.assert(pass,`expected last "${spyName}" call to return #{exp}`,`expected last "${spyName}" call to not return #{exp}`,value,lastResult)}),def(["toHaveNthReturnedWith","nthReturnedWith"],function(nthCall,value){let spy=getSpy(this),spyName=spy.getMockName(),isNot=utils.flag(this,"negate"),{type:callType,value:callResult}=spy.mock.results[nthCall-1],ordinalCall=`${ordinalOf(nthCall)} call`;!isNot&&callType==="throw"&&chai3.assert.fail(`expected ${ordinalCall} to return #{exp}, but instead it threw an error`);let nthCallReturn=equals(callResult,value);this.assert(nthCallReturn,`expected ${ordinalCall} "${spyName}" call to return #{exp}`,`expected ${ordinalCall} "${spyName}" call to not return #{exp}`,value,callResult)}),def("toSatisfy",function(matcher,message){return this.be.satisfy(matcher,message)}),utils.addProperty(chai3.Assertion.prototype,"resolves",function(){utils.flag(this,"promise","resolves"),utils.flag(this,"error",new Error("resolves"));let test=utils.flag(this,"vitest-test"),obj=utils.flag(this,"object");if(typeof(obj==null?void 0:obj.then)!="function")throw new TypeError(`You must provide a Promise to expect() when using .resolves, not '${typeof obj}'.`);let proxy=new Proxy(this,{get:(target,key,receiver)=>{let result=Reflect.get(target,key,receiver);return typeof result!="function"?result instanceof chai3.Assertion?proxy:result:async(...args)=>{let promise=obj.then(value=>(utils.flag(this,"object",value),result.call(this,...args)),err=>{throw new Error(`promise rejected "${String(err)}" instead of resolving`)});return recordAsyncExpect(test,promise)}}});return proxy}),utils.addProperty(chai3.Assertion.prototype,"rejects",function(){utils.flag(this,"promise","rejects"),utils.flag(this,"error",new Error("rejects"));let test=utils.flag(this,"vitest-test"),obj=utils.flag(this,"object"),wrapper=typeof obj=="function"?obj():obj;if(typeof(wrapper==null?void 0:wrapper.then)!="function")throw new TypeError(`You must provide a Promise to expect() when using .rejects, not '${typeof wrapper}'.`);let proxy=new Proxy(this,{get:(target,key,receiver)=>{let result=Reflect.get(target,key,receiver);return typeof result!="function"?result instanceof chai3.Assertion?proxy:result:async(...args)=>{let promise=wrapper.then(value=>{throw new Error(`promise resolved "${String(value)}" instead of rejecting`)},err=>(utils.flag(this,"object",err),result.call(this,...args)));return recordAsyncExpect(test,promise)}}});return proxy})};function getMatcherState(assertion,expect4){let obj=assertion._obj,isNot=import_chai.util.flag(assertion,"negate"),promise=import_chai.util.flag(assertion,"promise")||"",jestUtils={...getMatcherUtils(),diff,stringify,iterableEquality,subsetEquality};return{state:{...getState(expect4),isNot,utils:jestUtils,promise,equals,suppressedErrors:[]},isNot,obj}}var JestExtendError=class extends Error{constructor(message,actual,expected){super(message),this.actual=actual,this.expected=expected}};function JestExtendPlugin(expect4,matchers2){return(c,utils)=>{Object.entries(matchers2).forEach(([expectAssertionName,expectAssertion])=>{function expectWrapper(...args){let{state,isNot,obj}=getMatcherState(this,expect4),result=expectAssertion.call(state,obj,...args);if(result&&typeof result=="object"&&result instanceof Promise)return result.then(({pass:pass2,message:message2,actual:actual2,expected:expected2})=>{if(pass2&&isNot||!pass2&&!isNot)throw new JestExtendError(message2(),actual2,expected2)});let{pass,message,actual,expected}=result;if(pass&&isNot||!pass&&!isNot)throw new JestExtendError(message(),actual,expected)}let softWrapper=wrapSoft(utils,expectWrapper);utils.addMethod(globalThis[JEST_MATCHERS_OBJECT].matchers,expectAssertionName,softWrapper),utils.addMethod(c.Assertion.prototype,expectAssertionName,softWrapper);class CustomMatcher extends AsymmetricMatcher3{constructor(inverse=!1,...sample){super(sample,inverse)}asymmetricMatch(other){let{pass}=expectAssertion.call(this.getMatcherContext(expect4),other,...this.sample);return this.inverse?!pass:pass}toString(){return`${this.inverse?"not.":""}${expectAssertionName}`}getExpectedType(){return"any"}toAsymmetricMatcher(){return`${this.toString()}<${this.sample.map(String).join(", ")}>`}}Object.defineProperty(expect4,expectAssertionName,{configurable:!0,enumerable:!0,value:(...sample)=>new CustomMatcher(!1,...sample),writable:!0}),Object.defineProperty(expect4.not,expectAssertionName,{configurable:!0,enumerable:!0,value:(...sample)=>new CustomMatcher(!0,...sample),writable:!0})})}}var JestExtend=(chai3,utils)=>{utils.addMethod(chai3.expect,"extend",(expect4,expects)=>{chai3.use(JestExtendPlugin(expect4,expects))})};var matchers=__toESM(require("@testing-library/jest-dom/matchers"));function createExpect(){chai.use(JestExtend),chai.use(JestChaiExpect),chai.use(JestAsymmetricMatchers);let expect4=(value,message)=>{let{assertionCalls}=getState(expect4);return setState({assertionCalls:assertionCalls+1,soft:!1},expect4),chai.expect(value,message)};Object.assign(expect4,chai.expect),expect4.getState=()=>getState(expect4),expect4.setState=state=>setState(state,expect4),expect4.extend=expects=>chai.expect.extend(expect4,expects),expect4.soft=(...args)=>{let assert2=expect4(...args);return expect4.setState({soft:!0}),assert2},expect4.unreachable=message=>{chai.assert.fail(`expected${message?` "${message}" `:" "}not to be reached`)};function assertions(expected){let errorGen=()=>new Error(`expected number of assertions to be ${expected}, but got ${expect4.getState().assertionCalls}`);"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen})}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(error,hasAssertions),expect4.setState({isExpectingAssertions:!0,isExpectingAssertionsError:error})}return setState({assertionCalls:0,isExpectingAssertions:!1,isExpectingAssertionsError:null,expectedAssertionsNumber:null,expectedAssertionsNumberErrorGen:null},expect4),chai.util.addMethod(expect4,"assertions",assertions),chai.util.addMethod(expect4,"hasAssertions",hasAssertions),expect4.extend(matchers),expect4}var expect2=createExpect();Object.defineProperty(globalThis,GLOBAL_EXPECT,{value:expect2,writable:!0,configurable:!0});var import_client_logger=require("@storybook/client-logger"),import_instrumenter=require("@storybook/instrumenter"),domTestingLibrary=__toESM(require("@testing-library/dom")),import_user_event=__toESM(require("@testing-library/user-event")),import_ts_dedent=__toESM(require("ts-dedent")),testingLibrary=(0,import_instrumenter.instrument)({...domTestingLibrary},{intercept:(method,path)=>path[0]==="fireEvent"||method.startsWith("find")||method.startsWith("waitFor")});testingLibrary.screen=new Proxy(testingLibrary.screen,{get(target,prop,receiver){return import_client_logger.once.warn(import_ts_dedent.default`
|
|
57
|
+
`),msg);def(["toHaveBeenCalledTimes","toBeCalledTimes"],function(number){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length;return this.assert(callCount===number,`expected "${spyName}" to be called #{exp} times, but got ${callCount} times`,`expected "${spyName}" to not be called #{exp} times`,number,callCount,!1)}),def("toHaveBeenCalledOnce",function(){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length;return this.assert(callCount===1,`expected "${spyName}" to be called once, but got ${callCount} times`,`expected "${spyName}" to not be called once`,1,callCount,!1)}),def(["toHaveBeenCalled","toBeCalled"],function(){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length,called=callCount>0,isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[called,`expected "${spyName}" to be called at least once`,`expected "${spyName}" to not be called at all, but actually been called ${callCount} times`,!0,called]);if(called&&isNot&&(msg=formatCalls(spy,msg)),called&&isNot||!called&&!isNot)throw new AssertionError(msg)}),def(["toHaveBeenCalledWith","toBeCalledWith"],function(...args){let spy=getSpy(this),spyName=spy.getMockName(),pass=spy.mock.calls.some(callArg=>equals(callArg,args,[iterableEquality])),isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[pass,`expected "${spyName}" to be called with arguments: #{exp}`,`expected "${spyName}" to not be called with arguments: #{exp}`,args]);if(pass&&isNot||!pass&&!isNot)throw new AssertionError(formatCalls(spy,msg,args))}),def(["toHaveBeenNthCalledWith","nthCalledWith"],function(times,...args){let spy=getSpy(this),spyName=spy.getMockName(),nthCall=spy.mock.calls[times-1];this.assert(equals(nthCall,args,[iterableEquality]),`expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}`,`expected ${ordinalOf(times)} "${spyName}" call to not have been called with #{exp}`,args,nthCall)}),def(["toHaveBeenLastCalledWith","lastCalledWith"],function(...args){let spy=getSpy(this),spyName=spy.getMockName(),lastCall=spy.mock.calls[spy.mock.calls.length-1];this.assert(equals(lastCall,args,[iterableEquality]),`expected last "${spyName}" call to have been called with #{exp}`,`expected last "${spyName}" call to not have been called with #{exp}`,args,lastCall)}),def(["toThrow","toThrowError"],function(expected){if(typeof expected=="string"||typeof expected>"u"||expected instanceof RegExp)return this.throws(expected);let obj=this._obj,promise=utils.flag(this,"promise"),isNot=utils.flag(this,"negate"),thrown=null;if(promise==="rejects")thrown=obj;else if(promise==="resolves"&&typeof obj!="function"){if(isNot)return;{let message=utils.flag(this,"message")||"expected promise to throw an error, but it didn't",error={showDiff:!1};throw new AssertionError(message,error,utils.flag(this,"ssfi"))}}else{let isThrow=!1;try{obj()}catch(err){isThrow=!0,thrown=err}if(!isThrow&&!isNot){let message=utils.flag(this,"message")||"expected function to throw an error, but it didn't",error={showDiff:!1};throw new AssertionError(message,error,utils.flag(this,"ssfi"))}}if(typeof expected=="function"){let name=expected.name||expected.prototype.constructor.name;return this.assert(thrown&&thrown instanceof expected,`expected error to be instance of ${name}`,`expected error not to be instance of ${name}`,expected,thrown,!1)}if(expected instanceof Error)return this.assert(thrown&&expected.message===thrown.message,`expected error to have message: ${expected.message}`,`expected error not to have message: ${expected.message}`,expected.message,thrown&&thrown.message);if(typeof expected=="object"&&"asymmetricMatch"in expected&&typeof expected.asymmetricMatch=="function"){let matcher=expected;return this.assert(thrown&&matcher.asymmetricMatch(thrown),"expected error to match asymmetric matcher","expected error not to match asymmetric matcher",matcher.toString(),thrown,!1)}throw new Error(`"toThrow" expects string, RegExp, function, Error instance or asymmetric matcher, got "${typeof expected}"`)}),def(["toHaveReturned","toReturn"],function(){let spy=getSpy(this),spyName=spy.getMockName(),calledAndNotThrew=spy.mock.calls.length>0&&spy.mock.results.some(({type})=>type!=="throw");this.assert(calledAndNotThrew,`expected "${spyName}" to be successfully called at least once`,`expected "${spyName}" to not be successfully called`,calledAndNotThrew,!calledAndNotThrew,!1)}),def(["toHaveReturnedTimes","toReturnTimes"],function(times){let spy=getSpy(this),spyName=spy.getMockName(),successfulReturns=spy.mock.results.reduce((success,{type})=>type==="throw"?success:++success,0);this.assert(successfulReturns===times,`expected "${spyName}" to be successfully called ${times} times`,`expected "${spyName}" to not be successfully called ${times} times`,`expected number of returns: ${times}`,`received number of returns: ${successfulReturns}`,!1)}),def(["toHaveReturnedWith","toReturnWith"],function(value){let spy=getSpy(this),spyName=spy.getMockName(),pass=spy.mock.results.some(({type,value:result})=>type==="return"&&equals(value,result)),isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[pass,`expected "${spyName}" to return with: #{exp} at least once`,`expected "${spyName}" to not return with: #{exp}`,value]);if(pass&&isNot||!pass&&!isNot)throw new AssertionError(formatReturns(spy,msg,value))}),def(["toHaveLastReturnedWith","lastReturnedWith"],function(value){let spy=getSpy(this),spyName=spy.getMockName(),{value:lastResult}=spy.mock.results[spy.mock.results.length-1],pass=equals(lastResult,value);this.assert(pass,`expected last "${spyName}" call to return #{exp}`,`expected last "${spyName}" call to not return #{exp}`,value,lastResult)}),def(["toHaveNthReturnedWith","nthReturnedWith"],function(nthCall,value){let spy=getSpy(this),spyName=spy.getMockName(),isNot=utils.flag(this,"negate"),{type:callType,value:callResult}=spy.mock.results[nthCall-1],ordinalCall=`${ordinalOf(nthCall)} call`;!isNot&&callType==="throw"&&chai3.assert.fail(`expected ${ordinalCall} to return #{exp}, but instead it threw an error`);let nthCallReturn=equals(callResult,value);this.assert(nthCallReturn,`expected ${ordinalCall} "${spyName}" call to return #{exp}`,`expected ${ordinalCall} "${spyName}" call to not return #{exp}`,value,callResult)}),def("toSatisfy",function(matcher,message){return this.be.satisfy(matcher,message)}),utils.addProperty(chai3.Assertion.prototype,"resolves",function(){let error=new Error("resolves");utils.flag(this,"promise","resolves"),utils.flag(this,"error",error);let test=utils.flag(this,"vitest-test"),obj=utils.flag(this,"object");if(typeof(obj==null?void 0:obj.then)!="function")throw new TypeError(`You must provide a Promise to expect() when using .resolves, not '${typeof obj}'.`);let proxy=new Proxy(this,{get:(target,key,receiver)=>{let result=Reflect.get(target,key,receiver);return typeof result!="function"?result instanceof chai3.Assertion?proxy:result:async(...args)=>{let promise=obj.then(value=>(utils.flag(this,"object",value),result.call(this,...args)),err=>{let _error=new AssertionError(`promise rejected "${utils.inspect(err)}" instead of resolving`,{showDiff:!1});throw _error.stack=error.stack.replace(error.message,_error.message),_error});return recordAsyncExpect(test,promise)}}});return proxy}),utils.addProperty(chai3.Assertion.prototype,"rejects",function(){let error=new Error("rejects");utils.flag(this,"promise","rejects"),utils.flag(this,"error",error);let test=utils.flag(this,"vitest-test"),obj=utils.flag(this,"object"),wrapper=typeof obj=="function"?obj():obj;if(typeof(wrapper==null?void 0:wrapper.then)!="function")throw new TypeError(`You must provide a Promise to expect() when using .rejects, not '${typeof wrapper}'.`);let proxy=new Proxy(this,{get:(target,key,receiver)=>{let result=Reflect.get(target,key,receiver);return typeof result!="function"?result instanceof chai3.Assertion?proxy:result:async(...args)=>{let promise=wrapper.then(value=>{let _error=new AssertionError(`promise resolved "${utils.inspect(value)}" instead of rejecting`,{showDiff:!1});throw _error.stack=error.stack.replace(error.message,_error.message),_error},err=>(utils.flag(this,"object",err),result.call(this,...args)));return recordAsyncExpect(test,promise)}}});return proxy})};function getMatcherState(assertion,expect4){let obj=assertion._obj,isNot=import_chai.util.flag(assertion,"negate"),promise=import_chai.util.flag(assertion,"promise")||"",jestUtils={...getMatcherUtils(),diff,stringify,iterableEquality,subsetEquality};return{state:{...getState(expect4),isNot,utils:jestUtils,promise,equals,suppressedErrors:[]},isNot,obj}}var JestExtendError=class extends Error{constructor(message,actual,expected){super(message),this.actual=actual,this.expected=expected}};function JestExtendPlugin(expect4,matchers2){return(c,utils)=>{Object.entries(matchers2).forEach(([expectAssertionName,expectAssertion])=>{function expectWrapper(...args){let{state,isNot,obj}=getMatcherState(this,expect4),result=expectAssertion.call(state,obj,...args);if(result&&typeof result=="object"&&result instanceof Promise)return result.then(({pass:pass2,message:message2,actual:actual2,expected:expected2})=>{if(pass2&&isNot||!pass2&&!isNot)throw new JestExtendError(message2(),actual2,expected2)});let{pass,message,actual,expected}=result;if(pass&&isNot||!pass&&!isNot)throw new JestExtendError(message(),actual,expected)}let softWrapper=wrapSoft(utils,expectWrapper);utils.addMethod(globalThis[JEST_MATCHERS_OBJECT].matchers,expectAssertionName,softWrapper),utils.addMethod(c.Assertion.prototype,expectAssertionName,softWrapper);class CustomMatcher extends AsymmetricMatcher3{constructor(inverse=!1,...sample){super(sample,inverse)}asymmetricMatch(other){let{pass}=expectAssertion.call(this.getMatcherContext(expect4),other,...this.sample);return this.inverse?!pass:pass}toString(){return`${this.inverse?"not.":""}${expectAssertionName}`}getExpectedType(){return"any"}toAsymmetricMatcher(){return`${this.toString()}<${this.sample.map(String).join(", ")}>`}}Object.defineProperty(expect4,expectAssertionName,{configurable:!0,enumerable:!0,value:(...sample)=>new CustomMatcher(!1,...sample),writable:!0}),Object.defineProperty(expect4.not,expectAssertionName,{configurable:!0,enumerable:!0,value:(...sample)=>new CustomMatcher(!0,...sample),writable:!0})})}}var JestExtend=(chai3,utils)=>{utils.addMethod(chai3.expect,"extend",(expect4,expects)=>{chai3.use(JestExtendPlugin(expect4,expects))})};var matchers=__toESM(require("@testing-library/jest-dom/matchers"));function createExpect(){chai.use(JestExtend),chai.use(JestChaiExpect),chai.use(JestAsymmetricMatchers);let expect4=(value,message)=>{let{assertionCalls}=getState(expect4);return setState({assertionCalls:assertionCalls+1,soft:!1},expect4),chai.expect(value,message)};Object.assign(expect4,chai.expect),expect4.getState=()=>getState(expect4),expect4.setState=state=>setState(state,expect4),expect4.extend=expects=>chai.expect.extend(expect4,expects),expect4.soft=(...args)=>{let assert2=expect4(...args);return expect4.setState({soft:!0}),assert2},expect4.unreachable=message=>{chai.assert.fail(`expected${message?` "${message}" `:" "}not to be reached`)};function assertions(expected){let errorGen=()=>new Error(`expected number of assertions to be ${expected}, but got ${expect4.getState().assertionCalls}`);"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen})}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(error,hasAssertions),expect4.setState({isExpectingAssertions:!0,isExpectingAssertionsError:error})}return setState({assertionCalls:0,isExpectingAssertions:!1,isExpectingAssertionsError:null,expectedAssertionsNumber:null,expectedAssertionsNumberErrorGen:null},expect4),chai.util.addMethod(expect4,"assertions",assertions),chai.util.addMethod(expect4,"hasAssertions",hasAssertions),expect4.extend(matchers),expect4}var expect2=createExpect();Object.defineProperty(globalThis,GLOBAL_EXPECT,{value:expect2,writable:!0,configurable:!0});var import_client_logger=require("@storybook/client-logger"),import_instrumenter=require("@storybook/instrumenter"),domTestingLibrary=__toESM(require("@testing-library/dom")),import_user_event=__toESM(require("@testing-library/user-event")),import_ts_dedent=__toESM(require("ts-dedent")),testingLibrary=(0,import_instrumenter.instrument)({...domTestingLibrary},{intercept:(method,path)=>path[0]==="fireEvent"||method.startsWith("find")||method.startsWith("waitFor")});testingLibrary.screen=new Proxy(testingLibrary.screen,{get(target,prop,receiver){return import_client_logger.once.warn(import_ts_dedent.default`
|
|
58
58
|
You are using Testing Library's \`screen\` object. Use \`within(canvasElement)\` instead.
|
|
59
59
|
More info: https://storybook.js.org/docs/react/essentials/interactions
|
|
60
60
|
`),Reflect.get(target,prop,receiver)}});var{buildQueries,configure,createEvent,fireEvent,findAllByAltText,findAllByDisplayValue,findAllByLabelText,findAllByPlaceholderText,findAllByRole,findAllByTestId,findAllByText,findAllByTitle,findByAltText,findByDisplayValue,findByLabelText,findByPlaceholderText,findByRole,findByTestId,findByText,findByTitle,getAllByAltText,getAllByDisplayValue,getAllByLabelText,getAllByPlaceholderText,getAllByRole,getAllByTestId,getAllByText,getAllByTitle,getByAltText,getByDisplayValue,getByLabelText,getByPlaceholderText,getByRole,getByTestId,getByText,getByTitle,getConfig,getDefaultNormalizer,getElementError,getNodeText,getQueriesForElement,getRoles,getSuggestedQuery,isInaccessible,logDOM,logRoles,prettyDOM,queries,queryAllByAltText,queryAllByAttribute,queryAllByDisplayValue,queryAllByLabelText,queryAllByPlaceholderText,queryAllByRole,queryAllByTestId,queryAllByText,queryAllByTitle,queryByAltText,queryByAttribute,queryByDisplayValue,queryByLabelText,queryByPlaceholderText,queryByRole,queryByTestId,queryByText,queryByTitle,queryHelpers,screen,waitFor,waitForElementToBeRemoved,within,prettyFormat}=testingLibrary,{userEvent}=(0,import_instrumenter.instrument)({userEvent:import_user_event.default},{intercept:!0});var channel=import_preview_api.addons.getChannel();channel.on(import_core_events.FORCE_REMOUNT,()=>spies.forEach(mock=>mock.mockClear()));channel.on(import_core_events.STORY_RENDER_PHASE_CHANGED,({newPhase})=>{newPhase==="loading"&&spies.forEach(mock=>mock.mockClear())});var{expect:expect3}=(0,import_instrumenter2.instrument)({expect:expect2},{getKeys:(obj,depth)=>{let privateApi=["assert","__methods","__flags"];if(obj.constructor===import_chai2.default.Assertion){let keys2=Object.keys(Object.getPrototypeOf(obj)).filter(it=>!privateApi.includes(it));return depth>2?keys2:[...keys2,"not"]}return Object.keys(obj)},intercept:method=>method!=="expect"});0&&(module.exports={buildQueries,configure,createEvent,expect,findAllByAltText,findAllByDisplayValue,findAllByLabelText,findAllByPlaceholderText,findAllByRole,findAllByTestId,findAllByText,findAllByTitle,findByAltText,findByDisplayValue,findByLabelText,findByPlaceholderText,findByRole,findByTestId,findByText,findByTitle,fireEvent,fn,getAllByAltText,getAllByDisplayValue,getAllByLabelText,getAllByPlaceholderText,getAllByRole,getAllByTestId,getAllByText,getAllByTitle,getByAltText,getByDisplayValue,getByLabelText,getByPlaceholderText,getByRole,getByTestId,getByText,getByTitle,getConfig,getDefaultNormalizer,getElementError,getNodeText,getQueriesForElement,getRoles,getSuggestedQuery,isInaccessible,isMockFunction,logDOM,logRoles,prettyDOM,prettyFormat,queries,queryAllByAltText,queryAllByAttribute,queryAllByDisplayValue,queryAllByLabelText,queryAllByPlaceholderText,queryAllByRole,queryAllByTestId,queryAllByText,queryAllByTitle,queryByAltText,queryByAttribute,queryByDisplayValue,queryByLabelText,queryByPlaceholderText,queryByRole,queryByTestId,queryByText,queryByTitle,queryHelpers,screen,spies,spyOn,userEvent,waitFor,waitForElementToBeRemoved,within});
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { instrument } from '@storybook/instrumenter';
|
|
2
2
|
import * as chai from 'chai';
|
|
3
|
-
import chai__default, {
|
|
3
|
+
import chai__default, { util } from 'chai';
|
|
4
4
|
import { FORCE_REMOUNT, STORY_RENDER_PHASE_CHANGED } from '@storybook/core-events';
|
|
5
5
|
import { addons } from '@storybook/preview-api';
|
|
6
6
|
import { inspect as inspect$1 } from 'loupe';
|
|
@@ -33,14 +33,14 @@ ${difference}`);}return difference}function getFormatOptions(formatOptions,optio
|
|
|
33
33
|
`),bDisplay.split(`
|
|
34
34
|
`),aCompare.split(`
|
|
35
35
|
`),bCompare.split(`
|
|
36
|
-
`),options)}}__toESM(require_build(),1);__toESM(require_build2(),1);var IS_RECORD_SYMBOL="@@__IMMUTABLE_RECORD__@@",IS_COLLECTION_SYMBOL="@@__IMMUTABLE_ITERABLE__@@";function isImmutable(v){return v&&(v[IS_COLLECTION_SYMBOL]||v[IS_RECORD_SYMBOL])}var OBJECT_PROTO=Object.getPrototypeOf({});function getUnserializableMessage(err){return err instanceof Error?`<unserializable>: ${err.message}`:typeof err=="string"?`<unserializable>: ${err}`:"<unserializable>"}function serializeError(val,seen=new WeakMap){if(!val||typeof val=="string")return val;if(typeof val=="function")return `Function<${val.name||"anonymous"}>`;if(typeof val=="symbol")return val.toString();if(typeof val!="object")return val;if(isImmutable(val))return serializeError(val.toJSON(),seen);if(val instanceof Promise||val.constructor&&val.constructor.prototype==="AsyncFunction")return "Promise";if(typeof Element<"u"&&val instanceof Element)return val.tagName;if(typeof val.asymmetricMatch=="function")return `${val.toString()} ${format(val.sample)}`;if(seen.has(val))return seen.get(val);if(Array.isArray(val)){let clone2=new Array(val.length);return seen.set(val,clone2),val.forEach((e,i2)=>{try{clone2[i2]=serializeError(e,seen);}catch(err){clone2[i2]=getUnserializableMessage(err);}}),clone2}else {let clone2=Object.create(null);seen.set(val,clone2);let obj=val;for(;obj&&obj!==OBJECT_PROTO;)Object.getOwnPropertyNames(obj).forEach(key=>{if(!(key in clone2))try{clone2[key]=serializeError(val[key],seen);}catch(err){delete clone2[key],clone2[key]=getUnserializableMessage(err);}}),obj=Object.getPrototypeOf(obj);return clone2}}function normalizeErrorMessage(message){return message.replace(/__vite_ssr_import_\d+__\./g,"")}function processError(err){if(!err||typeof err!="object")return {message:err};if(err.stack&&(err.stackStr=String(err.stack)),err.name&&(err.nameStr=String(err.name)),err.showDiff||err.showDiff===void 0&&err.expected!==void 0&&err.actual!==void 0){let clonedActual=deepClone(err.actual,{forceWritable:!0}),clonedExpected=deepClone(err.expected,{forceWritable:!0}),{replacedActual,replacedExpected}=replaceAsymmetricMatcher(clonedActual,clonedExpected);err.diff=diff(replacedExpected,replacedActual);}typeof err.expected!="string"&&(err.expected=stringify(err.expected,10)),typeof err.actual!="string"&&(err.actual=stringify(err.actual,10));try{typeof err.message=="string"&&(err.message=normalizeErrorMessage(err.message)),typeof err.cause=="object"&&typeof err.cause.message=="string"&&(err.cause.message=normalizeErrorMessage(err.cause.message));}catch{}try{return serializeError(err)}catch(e){return serializeError(new Error(`Failed to fully serialize error: ${e?.message}
|
|
37
|
-
Inner error message: ${err?.message}`))}}function isAsymmetricMatcher(data){return getType(data)==="Object"&&typeof data.asymmetricMatch=="function"}function isReplaceable(obj1,obj2){let obj1Type=getType(obj1),obj2Type=getType(obj2);return obj1Type===obj2Type&&obj1Type==="Object"}function replaceAsymmetricMatcher(actual,expected,actualReplaced=new WeakSet,expectedReplaced=new WeakSet){return isReplaceable(actual,expected)?actualReplaced.has(actual)||expectedReplaced.has(expected)?{replacedActual:actual,replacedExpected:expected}:(actualReplaced.add(actual),expectedReplaced.add(expected),getOwnProperties(expected).forEach(key=>{let expectedValue=expected[key],actualValue=actual[key];if(isAsymmetricMatcher(expectedValue))expectedValue.asymmetricMatch(actualValue)&&(actual[key]=expectedValue);else if(isAsymmetricMatcher(actualValue))actualValue.asymmetricMatch(expectedValue)&&(expected[key]=actualValue);else if(isReplaceable(actualValue,expectedValue)){let replaced=replaceAsymmetricMatcher(actualValue,expectedValue,actualReplaced,expectedReplaced);actual[key]=replaced.replacedActual,expected[key]=replaced.replacedExpected;}}),{replacedActual:actual,replacedExpected:expected}):{replacedActual:actual,replacedExpected:expected}}var MATCHERS_OBJECT=Symbol.for("matchers-object"),JEST_MATCHERS_OBJECT=Symbol.for("$$jest-matchers-object-storybook"),GLOBAL_EXPECT=Symbol.for("expect-global");if(!Object.prototype.hasOwnProperty.call(globalThis,MATCHERS_OBJECT)){let globalState=new WeakMap,matchers2=Object.create(null);Object.defineProperty(globalThis,MATCHERS_OBJECT,{get:()=>globalState}),Object.defineProperty(globalThis,JEST_MATCHERS_OBJECT,{configurable:!0,get:()=>({state:globalState.get(globalThis[GLOBAL_EXPECT]),matchers:matchers2})});}function getState(expect4){return globalThis[MATCHERS_OBJECT].get(expect4)}function setState(state,expect4){let map=globalThis[MATCHERS_OBJECT],current=map.get(expect4)||{};Object.assign(current,state),map.set(expect4,current);}function getMatcherUtils(){let c=()=>getColors(),EXPECTED_COLOR=c().green,RECEIVED_COLOR=c().red,INVERTED_COLOR=c().inverse,BOLD_WEIGHT=c().bold,DIM_COLOR=c().dim;function matcherHint(matcherName,received="received",expected="expected",options={}){let{comment="",isDirectExpectCall=!1,isNot=!1,promise="",secondArgument="",expectedColor=EXPECTED_COLOR,receivedColor=RECEIVED_COLOR,secondArgumentColor=EXPECTED_COLOR}=options,hint="",dimString="expect";return !isDirectExpectCall&&received!==""&&(hint+=DIM_COLOR(`${dimString}(`)+receivedColor(received),dimString=")"),promise!==""&&(hint+=DIM_COLOR(`${dimString}.`)+promise,dimString=""),isNot&&(hint+=`${DIM_COLOR(`${dimString}.`)}not`,dimString=""),matcherName.includes(".")?dimString+=matcherName:(hint+=DIM_COLOR(`${dimString}.`)+matcherName,dimString=""),expected===""?dimString+="()":(hint+=DIM_COLOR(`${dimString}(`)+expectedColor(expected),secondArgument&&(hint+=DIM_COLOR(", ")+secondArgumentColor(secondArgument)),dimString=")"),comment!==""&&(dimString+=` // ${comment}`),dimString!==""&&(hint+=DIM_COLOR(dimString)),hint}let SPACE_SYMBOL="\xB7",replaceTrailingSpaces=text=>text.replace(/\s+$/gm,spaces=>SPACE_SYMBOL.repeat(spaces.length));return {EXPECTED_COLOR,RECEIVED_COLOR,INVERTED_COLOR,BOLD_WEIGHT,DIM_COLOR,matcherHint,printReceived:object=>RECEIVED_COLOR(replaceTrailingSpaces(stringify(object))),printExpected:value=>EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)))}}function equals(a,b2,customTesters,strictCheck){return customTesters=customTesters||[],eq(a,b2,[],[],customTesters,strictCheck?hasKey:hasDefinedKey)}function isAsymmetric(obj){return !!obj&&typeof obj=="object"&&"asymmetricMatch"in obj&&isA("Function",obj.asymmetricMatch)}function asymmetricMatch(a,b2){let asymmetricA=isAsymmetric(a),asymmetricB=isAsymmetric(b2);if(!(asymmetricA&&asymmetricB)){if(asymmetricA)return a.asymmetricMatch(b2);if(asymmetricB)return b2.asymmetricMatch(a)}}function eq(a,b2,aStack,bStack,customTesters,hasKey2){let result=!0,asymmetricResult=asymmetricMatch(a,b2);if(asymmetricResult!==void 0)return asymmetricResult;for(let i2=0;i2<customTesters.length;i2++){let customTesterResult=customTesters[i2](a,b2);if(customTesterResult!==void 0)return customTesterResult}if(a instanceof Error&&b2 instanceof Error)return a.message===b2.message;if(Object.is(a,b2))return !0;if(a===null||b2===null)return a===b2;let className=Object.prototype.toString.call(a);if(className!==Object.prototype.toString.call(b2))return !1;switch(className){case"[object Boolean]":case"[object String]":case"[object Number]":return typeof a!=typeof b2?!1:typeof a!="object"&&typeof b2!="object"?Object.is(a,b2):Object.is(a.valueOf(),b2.valueOf());case"[object Date]":{let numA=+a,numB=+b2;return numA===numB||Number.isNaN(numA)&&Number.isNaN(numB)}case"[object RegExp]":return a.source===b2.source&&a.flags===b2.flags}if(typeof a!="object"||typeof b2!="object")return !1;if(isDomNode(a)&&isDomNode(b2))return a.isEqualNode(b2);let length=aStack.length;for(;length--;){if(aStack[length]===a)return bStack[length]===b2;if(bStack[length]===b2)return !1}if(aStack.push(a),bStack.push(b2),className==="[object Array]"&&a.length!==b2.length)return !1;let aKeys=keys(a,hasKey2),key,size=aKeys.length;if(keys(b2,hasKey2).length!==size)return !1;for(;size--;)if(key=aKeys[size],result=hasKey2(b2,key)&&eq(a[key],b2[key],aStack,bStack,customTesters,hasKey2),!result)return !1;return aStack.pop(),bStack.pop(),result}function keys(obj,hasKey2){let keys2=[];for(let key in obj)hasKey2(obj,key)&&keys2.push(key);return keys2.concat(Object.getOwnPropertySymbols(obj).filter(symbol=>Object.getOwnPropertyDescriptor(obj,symbol).enumerable))}function hasDefinedKey(obj,key){return hasKey(obj,key)&&obj[key]!==void 0}function hasKey(obj,key){return Object.prototype.hasOwnProperty.call(obj,key)}function isA(typeName,value){return Object.prototype.toString.apply(value)===`[object ${typeName}]`}function isDomNode(obj){return obj!==null&&typeof obj=="object"&&"nodeType"in obj&&typeof obj.nodeType=="number"&&"nodeName"in obj&&typeof obj.nodeName=="string"&&"isEqualNode"in obj&&typeof obj.isEqualNode=="function"}var IS_KEYED_SENTINEL="@@__IMMUTABLE_KEYED__@@",IS_SET_SENTINEL="@@__IMMUTABLE_SET__@@",IS_ORDERED_SENTINEL="@@__IMMUTABLE_ORDERED__@@";function isImmutableUnorderedKeyed(maybeKeyed){return !!(maybeKeyed&&maybeKeyed[IS_KEYED_SENTINEL]&&!maybeKeyed[IS_ORDERED_SENTINEL])}function isImmutableUnorderedSet(maybeSet){return !!(maybeSet&&maybeSet[IS_SET_SENTINEL]&&!maybeSet[IS_ORDERED_SENTINEL])}var IteratorSymbol=Symbol.iterator;function hasIterator(object){return !!(object!=null&&object[IteratorSymbol])}function iterableEquality(a,b2,aStack=[],bStack=[]){if(typeof a!="object"||typeof b2!="object"||Array.isArray(a)||Array.isArray(b2)||!hasIterator(a)||!hasIterator(b2))return;if(a.constructor!==b2.constructor)return !1;let length=aStack.length;for(;length--;)if(aStack[length]===a)return bStack[length]===b2;aStack.push(a),bStack.push(b2);let iterableEqualityWithStack=(a2,b22)=>iterableEquality(a2,b22,[...aStack],[...bStack]);if(a.size!==void 0){if(a.size!==b2.size)return !1;if(isA("Set",a)||isImmutableUnorderedSet(a)){let allFound=!0;for(let aValue of a)if(!b2.has(aValue)){let has=!1;for(let bValue of b2)equals(aValue,bValue,[iterableEqualityWithStack])===!0&&(has=!0);if(has===!1){allFound=!1;break}}return aStack.pop(),bStack.pop(),allFound}else if(isA("Map",a)||isImmutableUnorderedKeyed(a)){let allFound=!0;for(let aEntry of a)if(!b2.has(aEntry[0])||!equals(aEntry[1],b2.get(aEntry[0]),[iterableEqualityWithStack])){let has=!1;for(let bEntry of b2){let matchedKey=equals(aEntry[0],bEntry[0],[iterableEqualityWithStack]),matchedValue=!1;matchedKey===!0&&(matchedValue=equals(aEntry[1],bEntry[1],[iterableEqualityWithStack])),matchedValue===!0&&(has=!0);}if(has===!1){allFound=!1;break}}return aStack.pop(),bStack.pop(),allFound}}let bIterator=b2[IteratorSymbol]();for(let aValue of a){let nextB=bIterator.next();if(nextB.done||!equals(aValue,nextB.value,[iterableEqualityWithStack]))return !1}return bIterator.next().done?(aStack.pop(),bStack.pop(),!0):!1}function hasPropertyInObject(object,key){return !object||typeof object!="object"||object===Object.prototype?!1:Object.prototype.hasOwnProperty.call(object,key)||hasPropertyInObject(Object.getPrototypeOf(object),key)}function isObjectWithKeys(a){return isObject(a)&&!(a instanceof Error)&&!Array.isArray(a)&&!(a instanceof Date)}function subsetEquality(object,subset){let subsetEqualityWithContext=(seenReferences=new WeakMap)=>(object2,subset2)=>{if(isObjectWithKeys(subset2))return Object.keys(subset2).every(key=>{if(isObjectWithKeys(subset2[key])){if(seenReferences.has(subset2[key]))return equals(object2[key],subset2[key],[iterableEquality]);seenReferences.set(subset2[key],!0);}let result=object2!=null&&hasPropertyInObject(object2,key)&&equals(object2[key],subset2[key],[iterableEquality,subsetEqualityWithContext(seenReferences)]);return seenReferences.delete(subset2[key]),result})};return subsetEqualityWithContext()(object,subset)}function typeEquality(a,b2){if(!(a==null||b2==null||a.constructor===b2.constructor))return !1}function arrayBufferEquality(a,b2){let dataViewA=a,dataViewB=b2;if(!(a instanceof DataView&&b2 instanceof DataView)){if(!(a instanceof ArrayBuffer)||!(b2 instanceof ArrayBuffer))return;dataViewA=new DataView(a),dataViewB=new DataView(b2);}if(dataViewA.byteLength!==dataViewB.byteLength)return !1;for(let i2=0;i2<dataViewA.byteLength;i2++)if(dataViewA.getUint8(i2)!==dataViewB.getUint8(i2))return !1;return !0}function sparseArrayEquality(a,b2){if(!Array.isArray(a)||!Array.isArray(b2))return;let aKeys=Object.keys(a),bKeys=Object.keys(b2);return equals(a,b2,[iterableEquality,typeEquality],!0)&&equals(aKeys,bKeys)}function generateToBeMessage(deepEqualityName,expected="#{this}",actual="#{exp}"){let toBeMessage=`expected ${expected} to be ${actual} // Object.is equality`;return ["toStrictEqual","toEqual"].includes(deepEqualityName)?`${toBeMessage}
|
|
36
|
+
`),options)}}function isMockFunction2(fn2){return typeof fn2=="function"&&"_isMockFunction"in fn2&&fn2._isMockFunction}__toESM(require_build(),1);__toESM(require_build2(),1);var IS_RECORD_SYMBOL="@@__IMMUTABLE_RECORD__@@",IS_COLLECTION_SYMBOL="@@__IMMUTABLE_ITERABLE__@@";function isImmutable(v){return v&&(v[IS_COLLECTION_SYMBOL]||v[IS_RECORD_SYMBOL])}var OBJECT_PROTO=Object.getPrototypeOf({});function getUnserializableMessage(err){return err instanceof Error?`<unserializable>: ${err.message}`:typeof err=="string"?`<unserializable>: ${err}`:"<unserializable>"}function serializeError(val,seen=new WeakMap){if(!val||typeof val=="string")return val;if(typeof val=="function")return `Function<${val.name||"anonymous"}>`;if(typeof val=="symbol")return val.toString();if(typeof val!="object")return val;if(isImmutable(val))return serializeError(val.toJSON(),seen);if(val instanceof Promise||val.constructor&&val.constructor.prototype==="AsyncFunction")return "Promise";if(typeof Element<"u"&&val instanceof Element)return val.tagName;if(typeof val.asymmetricMatch=="function")return `${val.toString()} ${format(val.sample)}`;if(seen.has(val))return seen.get(val);if(Array.isArray(val)){let clone2=new Array(val.length);return seen.set(val,clone2),val.forEach((e,i2)=>{try{clone2[i2]=serializeError(e,seen);}catch(err){clone2[i2]=getUnserializableMessage(err);}}),clone2}else {let clone2=Object.create(null);seen.set(val,clone2);let obj=val;for(;obj&&obj!==OBJECT_PROTO;)Object.getOwnPropertyNames(obj).forEach(key=>{if(!(key in clone2))try{clone2[key]=serializeError(val[key],seen);}catch(err){delete clone2[key],clone2[key]=getUnserializableMessage(err);}}),obj=Object.getPrototypeOf(obj);return clone2}}function normalizeErrorMessage(message){return message.replace(/__vite_ssr_import_\d+__\./g,"")}function processError(err,diffOptions){if(!err||typeof err!="object")return {message:err};if(err.stack&&(err.stackStr=String(err.stack)),err.name&&(err.nameStr=String(err.name)),err.showDiff||err.showDiff===void 0&&err.expected!==void 0&&err.actual!==void 0){let clonedActual=deepClone(err.actual,{forceWritable:!0}),clonedExpected=deepClone(err.expected,{forceWritable:!0}),{replacedActual,replacedExpected}=replaceAsymmetricMatcher(clonedActual,clonedExpected);err.diff=diff(replacedExpected,replacedActual,diffOptions);}typeof err.expected!="string"&&(err.expected=stringify(err.expected,10)),typeof err.actual!="string"&&(err.actual=stringify(err.actual,10));try{typeof err.message=="string"&&(err.message=normalizeErrorMessage(err.message)),typeof err.cause=="object"&&typeof err.cause.message=="string"&&(err.cause.message=normalizeErrorMessage(err.cause.message));}catch{}try{return serializeError(err)}catch(e){return serializeError(new Error(`Failed to fully serialize error: ${e?.message}
|
|
37
|
+
Inner error message: ${err?.message}`))}}function isAsymmetricMatcher(data){return getType(data)==="Object"&&typeof data.asymmetricMatch=="function"}function isReplaceable(obj1,obj2){let obj1Type=getType(obj1),obj2Type=getType(obj2);return obj1Type===obj2Type&&obj1Type==="Object"}function replaceAsymmetricMatcher(actual,expected,actualReplaced=new WeakSet,expectedReplaced=new WeakSet){return isReplaceable(actual,expected)?actualReplaced.has(actual)||expectedReplaced.has(expected)?{replacedActual:actual,replacedExpected:expected}:(actualReplaced.add(actual),expectedReplaced.add(expected),getOwnProperties(expected).forEach(key=>{let expectedValue=expected[key],actualValue=actual[key];if(isAsymmetricMatcher(expectedValue))expectedValue.asymmetricMatch(actualValue)&&(actual[key]=expectedValue);else if(isAsymmetricMatcher(actualValue))actualValue.asymmetricMatch(expectedValue)&&(expected[key]=actualValue);else if(isReplaceable(actualValue,expectedValue)){let replaced=replaceAsymmetricMatcher(actualValue,expectedValue,actualReplaced,expectedReplaced);actual[key]=replaced.replacedActual,expected[key]=replaced.replacedExpected;}}),{replacedActual:actual,replacedExpected:expected}):{replacedActual:actual,replacedExpected:expected}}var MATCHERS_OBJECT=Symbol.for("matchers-object"),JEST_MATCHERS_OBJECT=Symbol.for("$$jest-matchers-object-storybook"),GLOBAL_EXPECT=Symbol.for("expect-global");if(!Object.prototype.hasOwnProperty.call(globalThis,MATCHERS_OBJECT)){let globalState=new WeakMap;Object.defineProperty(globalThis,MATCHERS_OBJECT,{get:()=>globalState});}if(!Object.prototype.hasOwnProperty.call(globalThis,JEST_MATCHERS_OBJECT)){let matchers2=Object.create(null);Object.defineProperty(globalThis,JEST_MATCHERS_OBJECT,{configurable:!0,get:()=>({state:globalThis[MATCHERS_OBJECT].get(globalThis[GLOBAL_EXPECT]),matchers:matchers2})});}function getState(expect4){return globalThis[MATCHERS_OBJECT].get(expect4)}function setState(state,expect4){let map=globalThis[MATCHERS_OBJECT],current=map.get(expect4)||{};Object.assign(current,state),map.set(expect4,current);}function getMatcherUtils(){let c=()=>getColors(),EXPECTED_COLOR=c().green,RECEIVED_COLOR=c().red,INVERTED_COLOR=c().inverse,BOLD_WEIGHT=c().bold,DIM_COLOR=c().dim;function matcherHint(matcherName,received="received",expected="expected",options={}){let{comment="",isDirectExpectCall=!1,isNot=!1,promise="",secondArgument="",expectedColor=EXPECTED_COLOR,receivedColor=RECEIVED_COLOR,secondArgumentColor=EXPECTED_COLOR}=options,hint="",dimString="expect";return !isDirectExpectCall&&received!==""&&(hint+=DIM_COLOR(`${dimString}(`)+receivedColor(received),dimString=")"),promise!==""&&(hint+=DIM_COLOR(`${dimString}.`)+promise,dimString=""),isNot&&(hint+=`${DIM_COLOR(`${dimString}.`)}not`,dimString=""),matcherName.includes(".")?dimString+=matcherName:(hint+=DIM_COLOR(`${dimString}.`)+matcherName,dimString=""),expected===""?dimString+="()":(hint+=DIM_COLOR(`${dimString}(`)+expectedColor(expected),secondArgument&&(hint+=DIM_COLOR(", ")+secondArgumentColor(secondArgument)),dimString=")"),comment!==""&&(dimString+=` // ${comment}`),dimString!==""&&(hint+=DIM_COLOR(dimString)),hint}let SPACE_SYMBOL="\xB7",replaceTrailingSpaces=text=>text.replace(/\s+$/gm,spaces=>SPACE_SYMBOL.repeat(spaces.length));return {EXPECTED_COLOR,RECEIVED_COLOR,INVERTED_COLOR,BOLD_WEIGHT,DIM_COLOR,matcherHint,printReceived:object=>RECEIVED_COLOR(replaceTrailingSpaces(stringify(object))),printExpected:value=>EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)))}}function equals(a,b2,customTesters,strictCheck){return customTesters=customTesters||[],eq(a,b2,[],[],customTesters,strictCheck?hasKey:hasDefinedKey)}function isAsymmetric(obj){return !!obj&&typeof obj=="object"&&"asymmetricMatch"in obj&&isA("Function",obj.asymmetricMatch)}function asymmetricMatch(a,b2){let asymmetricA=isAsymmetric(a),asymmetricB=isAsymmetric(b2);if(!(asymmetricA&&asymmetricB)){if(asymmetricA)return a.asymmetricMatch(b2);if(asymmetricB)return b2.asymmetricMatch(a)}}function eq(a,b2,aStack,bStack,customTesters,hasKey2){let result=!0,asymmetricResult=asymmetricMatch(a,b2);if(asymmetricResult!==void 0)return asymmetricResult;for(let i2=0;i2<customTesters.length;i2++){let customTesterResult=customTesters[i2](a,b2);if(customTesterResult!==void 0)return customTesterResult}if(a instanceof Error&&b2 instanceof Error)return a.message===b2.message;if(Object.is(a,b2))return !0;if(a===null||b2===null)return a===b2;let className=Object.prototype.toString.call(a);if(className!==Object.prototype.toString.call(b2))return !1;switch(className){case"[object Boolean]":case"[object String]":case"[object Number]":return typeof a!=typeof b2?!1:typeof a!="object"&&typeof b2!="object"?Object.is(a,b2):Object.is(a.valueOf(),b2.valueOf());case"[object Date]":{let numA=+a,numB=+b2;return numA===numB||Number.isNaN(numA)&&Number.isNaN(numB)}case"[object RegExp]":return a.source===b2.source&&a.flags===b2.flags}if(typeof a!="object"||typeof b2!="object")return !1;if(isDomNode(a)&&isDomNode(b2))return a.isEqualNode(b2);let length=aStack.length;for(;length--;){if(aStack[length]===a)return bStack[length]===b2;if(bStack[length]===b2)return !1}if(aStack.push(a),bStack.push(b2),className==="[object Array]"&&a.length!==b2.length)return !1;let aKeys=keys(a,hasKey2),key,size=aKeys.length;if(keys(b2,hasKey2).length!==size)return !1;for(;size--;)if(key=aKeys[size],result=hasKey2(b2,key)&&eq(a[key],b2[key],aStack,bStack,customTesters,hasKey2),!result)return !1;return aStack.pop(),bStack.pop(),result}function keys(obj,hasKey2){let keys2=[];for(let key in obj)hasKey2(obj,key)&&keys2.push(key);return keys2.concat(Object.getOwnPropertySymbols(obj).filter(symbol=>Object.getOwnPropertyDescriptor(obj,symbol).enumerable))}function hasDefinedKey(obj,key){return hasKey(obj,key)&&obj[key]!==void 0}function hasKey(obj,key){return Object.prototype.hasOwnProperty.call(obj,key)}function isA(typeName,value){return Object.prototype.toString.apply(value)===`[object ${typeName}]`}function isDomNode(obj){return obj!==null&&typeof obj=="object"&&"nodeType"in obj&&typeof obj.nodeType=="number"&&"nodeName"in obj&&typeof obj.nodeName=="string"&&"isEqualNode"in obj&&typeof obj.isEqualNode=="function"}var IS_KEYED_SENTINEL="@@__IMMUTABLE_KEYED__@@",IS_SET_SENTINEL="@@__IMMUTABLE_SET__@@",IS_ORDERED_SENTINEL="@@__IMMUTABLE_ORDERED__@@";function isImmutableUnorderedKeyed(maybeKeyed){return !!(maybeKeyed&&maybeKeyed[IS_KEYED_SENTINEL]&&!maybeKeyed[IS_ORDERED_SENTINEL])}function isImmutableUnorderedSet(maybeSet){return !!(maybeSet&&maybeSet[IS_SET_SENTINEL]&&!maybeSet[IS_ORDERED_SENTINEL])}var IteratorSymbol=Symbol.iterator;function hasIterator(object){return !!(object!=null&&object[IteratorSymbol])}function iterableEquality(a,b2,aStack=[],bStack=[]){if(typeof a!="object"||typeof b2!="object"||Array.isArray(a)||Array.isArray(b2)||!hasIterator(a)||!hasIterator(b2))return;if(a.constructor!==b2.constructor)return !1;let length=aStack.length;for(;length--;)if(aStack[length]===a)return bStack[length]===b2;aStack.push(a),bStack.push(b2);let iterableEqualityWithStack=(a2,b22)=>iterableEquality(a2,b22,[...aStack],[...bStack]);if(a.size!==void 0){if(a.size!==b2.size)return !1;if(isA("Set",a)||isImmutableUnorderedSet(a)){let allFound=!0;for(let aValue of a)if(!b2.has(aValue)){let has=!1;for(let bValue of b2)equals(aValue,bValue,[iterableEqualityWithStack])===!0&&(has=!0);if(has===!1){allFound=!1;break}}return aStack.pop(),bStack.pop(),allFound}else if(isA("Map",a)||isImmutableUnorderedKeyed(a)){let allFound=!0;for(let aEntry of a)if(!b2.has(aEntry[0])||!equals(aEntry[1],b2.get(aEntry[0]),[iterableEqualityWithStack])){let has=!1;for(let bEntry of b2){let matchedKey=equals(aEntry[0],bEntry[0],[iterableEqualityWithStack]),matchedValue=!1;matchedKey===!0&&(matchedValue=equals(aEntry[1],bEntry[1],[iterableEqualityWithStack])),matchedValue===!0&&(has=!0);}if(has===!1){allFound=!1;break}}return aStack.pop(),bStack.pop(),allFound}}let bIterator=b2[IteratorSymbol]();for(let aValue of a){let nextB=bIterator.next();if(nextB.done||!equals(aValue,nextB.value,[iterableEqualityWithStack]))return !1}return bIterator.next().done?(aStack.pop(),bStack.pop(),!0):!1}function hasPropertyInObject(object,key){return !object||typeof object!="object"||object===Object.prototype?!1:Object.prototype.hasOwnProperty.call(object,key)||hasPropertyInObject(Object.getPrototypeOf(object),key)}function isObjectWithKeys(a){return isObject(a)&&!(a instanceof Error)&&!Array.isArray(a)&&!(a instanceof Date)}function subsetEquality(object,subset){let subsetEqualityWithContext=(seenReferences=new WeakMap)=>(object2,subset2)=>{if(isObjectWithKeys(subset2))return Object.keys(subset2).every(key=>{if(isObjectWithKeys(subset2[key])){if(seenReferences.has(subset2[key]))return equals(object2[key],subset2[key],[iterableEquality]);seenReferences.set(subset2[key],!0);}let result=object2!=null&&hasPropertyInObject(object2,key)&&equals(object2[key],subset2[key],[iterableEquality,subsetEqualityWithContext(seenReferences)]);return seenReferences.delete(subset2[key]),result})};return subsetEqualityWithContext()(object,subset)}function typeEquality(a,b2){if(!(a==null||b2==null||a.constructor===b2.constructor))return !1}function arrayBufferEquality(a,b2){let dataViewA=a,dataViewB=b2;if(!(a instanceof DataView&&b2 instanceof DataView)){if(!(a instanceof ArrayBuffer)||!(b2 instanceof ArrayBuffer))return;try{dataViewA=new DataView(a),dataViewB=new DataView(b2);}catch{return}}if(dataViewA.byteLength!==dataViewB.byteLength)return !1;for(let i2=0;i2<dataViewA.byteLength;i2++)if(dataViewA.getUint8(i2)!==dataViewB.getUint8(i2))return !1;return !0}function sparseArrayEquality(a,b2){if(!Array.isArray(a)||!Array.isArray(b2))return;let aKeys=Object.keys(a),bKeys=Object.keys(b2);return equals(a,b2,[iterableEquality,typeEquality],!0)&&equals(aKeys,bKeys)}function generateToBeMessage(deepEqualityName,expected="#{this}",actual="#{exp}"){let toBeMessage=`expected ${expected} to be ${actual} // Object.is equality`;return ["toStrictEqual","toEqual"].includes(deepEqualityName)?`${toBeMessage}
|
|
38
38
|
|
|
39
39
|
If it should pass with deep equality, replace "toBe" with "${deepEqualityName}"
|
|
40
40
|
|
|
41
41
|
Expected: ${expected}
|
|
42
42
|
Received: serializes to the same string
|
|
43
|
-
`:toBeMessage}var AsymmetricMatcher3=class{constructor(sample,inverse=!1){this.sample=sample,this.inverse=inverse;}$$typeof=Symbol.for("jest.asymmetricMatcher");getMatcherContext(expect4){return {...getState(expect4||globalThis[GLOBAL_EXPECT]),equals,isNot:this.inverse,utils:{...getMatcherUtils(),diff,stringify,iterableEquality,subsetEquality}}}},StringContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){if(!isA("String",sample))throw new Error("Expected is not a string");super(sample,inverse);}asymmetricMatch(other){let result=isA("String",other)&&other.includes(this.sample);return this.inverse?!result:result}toString(){return `String${this.inverse?"Not":""}Containing`}getExpectedType(){return "string"}},Anything=class extends AsymmetricMatcher3{asymmetricMatch(other){return other!=null}toString(){return "Anything"}toAsymmetricMatcher(){return "Anything"}},ObjectContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){super(sample,inverse);}getPrototype(obj){return Object.getPrototypeOf?Object.getPrototypeOf(obj):obj.constructor.prototype===obj?null:obj.constructor.prototype}hasProperty(obj,property){return obj?Object.prototype.hasOwnProperty.call(obj,property)?!0:this.hasProperty(this.getPrototype(obj),property):!1}asymmetricMatch(other){if(typeof this.sample!="object")throw new TypeError(`You must provide an object to ${this.toString()}, not '${typeof this.sample}'.`);let result=!0;for(let property in this.sample)if(!this.hasProperty(other,property)||!equals(this.sample[property],other[property])){result=!1;break}return this.inverse?!result:result}toString(){return `Object${this.inverse?"Not":""}Containing`}getExpectedType(){return "object"}},ArrayContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){super(sample,inverse);}asymmetricMatch(other){if(!Array.isArray(this.sample))throw new TypeError(`You must provide an array to ${this.toString()}, not '${typeof this.sample}'.`);let result=this.sample.length===0||Array.isArray(other)&&this.sample.every(item=>other.some(another=>equals(item,another)));return this.inverse?!result:result}toString(){return `Array${this.inverse?"Not":""}Containing`}getExpectedType(){return "array"}},Any=class extends AsymmetricMatcher3{constructor(sample){if(typeof sample>"u")throw new TypeError("any() expects to be passed a constructor function. Please pass one or use anything() to match any object.");super(sample);}fnNameFor(func){if(func.name)return func.name;let matches=Function.prototype.toString.call(func).match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/);return matches?matches[1]:"<anonymous>"}asymmetricMatch(other){return this.sample===String?typeof other=="string"||other instanceof String:this.sample===Number?typeof other=="number"||other instanceof Number:this.sample===Function?typeof other=="function"||other instanceof Function:this.sample===Boolean?typeof other=="boolean"||other instanceof Boolean:this.sample===BigInt?typeof other=="bigint"||other instanceof BigInt:this.sample===Symbol?typeof other=="symbol"||other instanceof Symbol:this.sample===Object?typeof other=="object":other instanceof this.sample}toString(){return "Any"}getExpectedType(){return this.sample===String?"string":this.sample===Number?"number":this.sample===Function?"function":this.sample===Object?"object":this.sample===Boolean?"boolean":this.fnNameFor(this.sample)}toAsymmetricMatcher(){return `Any<${this.fnNameFor(this.sample)}>`}},StringMatching=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){if(!isA("String",sample)&&!isA("RegExp",sample))throw new Error("Expected is not a String or a RegExp");super(new RegExp(sample),inverse);}asymmetricMatch(other){let result=isA("String",other)&&this.sample.test(other);return this.inverse?!result:result}toString(){return `String${this.inverse?"Not":""}Matching`}getExpectedType(){return "string"}},JestAsymmetricMatchers=(chai3,utils)=>{utils.addMethod(chai3.expect,"anything",()=>new Anything),utils.addMethod(chai3.expect,"any",expected=>new Any(expected)),utils.addMethod(chai3.expect,"stringContaining",expected=>new StringContaining(expected)),utils.addMethod(chai3.expect,"objectContaining",expected=>new ObjectContaining(expected)),utils.addMethod(chai3.expect,"arrayContaining",expected=>new ArrayContaining(expected)),utils.addMethod(chai3.expect,"stringMatching",expected=>new StringMatching(expected)),chai3.expect.not={stringContaining:expected=>new StringContaining(expected,!0),objectContaining:expected=>new ObjectContaining(expected,!0),arrayContaining:expected=>new ArrayContaining(expected,!0),stringMatching:expected=>new StringMatching(expected,!0)};};function recordAsyncExpect(test,promise){return test&&promise instanceof Promise&&(promise=promise.finally(()=>{let index=test.promises.indexOf(promise);index!==-1&&test.promises.splice(index,1);}),test.promises||(test.promises=[]),test.promises.push(promise)),promise}function wrapSoft(utils,fn2){return function(...args){var _a;let test=utils.flag(this,"vitest-test");if(!(test?.context._local?test.context.expect.getState():getState(globalThis[GLOBAL_EXPECT])).soft)return fn2.apply(this,args);if(!test)throw new Error("expect.soft() can only be used inside a test");try{return fn2.apply(this,args)}catch(err){test.result||(test.result={state:"fail"}),test.result.state="fail",(_a=test.result).errors||(_a.errors=[]),test.result.errors.push(processError(err));}}}var JestChaiExpect=(chai3,utils)=>{let c=()=>getColors();function def(name,fn2){let addMethod=n=>{let softWrapper=wrapSoft(utils,fn2);utils.addMethod(chai3.Assertion.prototype,n,softWrapper),utils.addMethod(globalThis[JEST_MATCHERS_OBJECT].matchers,n,softWrapper);};Array.isArray(name)?name.forEach(n=>addMethod(n)):addMethod(name);}["throw","throws","Throw"].forEach(m2=>{utils.overwriteMethod(chai3.Assertion.prototype,m2,_super=>function(...args){let promise=utils.flag(this,"promise"),object=utils.flag(this,"object"),isNot=utils.flag(this,"negate");if(promise==="rejects")utils.flag(this,"object",()=>{throw object});else if(promise==="resolves"&&typeof object!="function"){if(isNot)return;{let message=utils.flag(this,"message")||"expected promise to throw an error, but it didn't",error={showDiff:!1};throw new AssertionError(message,error,utils.flag(this,"ssfi"))}}_super.apply(this,args);});}),def("withTest",function(test){return utils.flag(this,"vitest-test",test),this}),def("toEqual",function(expected){let actual=utils.flag(this,"object"),equal=equals(actual,expected,[iterableEquality]);return this.assert(equal,"expected #{this} to deeply equal #{exp}","expected #{this} to not deeply equal #{exp}",expected,actual)}),def("toStrictEqual",function(expected){let obj=utils.flag(this,"object"),equal=equals(obj,expected,[iterableEquality,typeEquality,sparseArrayEquality,arrayBufferEquality],!0);return this.assert(equal,"expected #{this} to strictly equal #{exp}","expected #{this} to not strictly equal #{exp}",expected,obj)}),def("toBe",function(expected){let actual=this._obj,pass=Object.is(actual,expected),deepEqualityName="";return pass||(equals(actual,expected,[iterableEquality,typeEquality,sparseArrayEquality,arrayBufferEquality],!0)?deepEqualityName="toStrictEqual":equals(actual,expected,[iterableEquality])&&(deepEqualityName="toEqual")),this.assert(pass,generateToBeMessage(deepEqualityName),"expected #{this} not to be #{exp} // Object.is equality",expected,actual)}),def("toMatchObject",function(expected){let actual=this._obj;return this.assert(equals(actual,expected,[iterableEquality,subsetEquality]),"expected #{this} to match object #{exp}","expected #{this} to not match object #{exp}",expected,actual)}),def("toMatch",function(expected){return typeof expected=="string"?this.include(expected):this.match(expected)}),def("toContain",function(item){return this.contain(item)}),def("toContainEqual",function(expected){let obj=utils.flag(this,"object"),index=Array.from(obj).findIndex(item=>equals(item,expected));this.assert(index!==-1,"expected #{this} to deep equally contain #{exp}","expected #{this} to not deep equally contain #{exp}",expected);}),def("toBeTruthy",function(){let obj=utils.flag(this,"object");this.assert(!!obj,"expected #{this} to be truthy","expected #{this} to not be truthy",obj,!1);}),def("toBeFalsy",function(){let obj=utils.flag(this,"object");this.assert(!obj,"expected #{this} to be falsy","expected #{this} to not be falsy",obj,!1);}),def("toBeGreaterThan",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual>expected,`expected ${actual} to be greater than ${expected}`,`expected ${actual} to be not greater than ${expected}`,actual,expected,!1)}),def("toBeGreaterThanOrEqual",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual>=expected,`expected ${actual} to be greater than or equal to ${expected}`,`expected ${actual} to be not greater than or equal to ${expected}`,actual,expected,!1)}),def("toBeLessThan",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual<expected,`expected ${actual} to be less than ${expected}`,`expected ${actual} to be not less than ${expected}`,actual,expected,!1)}),def("toBeLessThanOrEqual",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual<=expected,`expected ${actual} to be less than or equal to ${expected}`,`expected ${actual} to be not less than or equal to ${expected}`,actual,expected,!1)}),def("toBeNaN",function(){return this.be.NaN}),def("toBeUndefined",function(){return this.be.undefined}),def("toBeNull",function(){return this.be.null}),def("toBeDefined",function(){let negate=utils.flag(this,"negate");return utils.flag(this,"negate",!1),negate?this.be.undefined:this.not.be.undefined}),def("toBeTypeOf",function(expected){let actual=typeof this._obj,equal=expected===actual;return this.assert(equal,"expected #{this} to be type of #{exp}","expected #{this} not to be type of #{exp}",expected,actual)}),def("toBeInstanceOf",function(obj){return this.instanceOf(obj)}),def("toHaveLength",function(length){return this.have.length(length)}),def("toHaveProperty",function(...args){Array.isArray(args[0])&&(args[0]=args[0].map(key=>String(key).replace(/([.[\]])/g,"\\$1")).join("."));let actual=this._obj,[propertyName,expected]=args,getValue=()=>Object.prototype.hasOwnProperty.call(actual,propertyName)?{value:actual[propertyName],exists:!0}:utils.getPathInfo(actual,propertyName),{value,exists}=getValue(),pass=exists&&(args.length===1||equals(expected,value)),valueString=args.length===1?"":` with value ${utils.objDisplay(expected)}`;return this.assert(pass,`expected #{this} to have property "${propertyName}"${valueString}`,`expected #{this} to not have property "${propertyName}"${valueString}`,actual)}),def("toBeCloseTo",function(received,precision=2){let expected=this._obj,pass=!1,expectedDiff=0,receivedDiff=0;return received===Number.POSITIVE_INFINITY&&expected===Number.POSITIVE_INFINITY||received===Number.NEGATIVE_INFINITY&&expected===Number.NEGATIVE_INFINITY?pass=!0:(expectedDiff=10**-precision/2,receivedDiff=Math.abs(expected-received),pass=receivedDiff<expectedDiff),this.assert(pass,`expected #{this} to be close to #{exp}, received difference is ${receivedDiff}, but expected ${expectedDiff}`,`expected #{this} to not be close to #{exp}, received difference is ${receivedDiff}, but expected ${expectedDiff}`,received,expected,!1)});let assertIsMock=assertion=>{if(!isMockFunction(assertion._obj))throw new TypeError(`${utils.inspect(assertion._obj)} is not a spy or a call to a spy!`)},getSpy=assertion=>(assertIsMock(assertion),assertion._obj),ordinalOf=i2=>{let j=i2%10,k=i2%100;return j===1&&k!==11?`${i2}st`:j===2&&k!==12?`${i2}nd`:j===3&&k!==13?`${i2}rd`:`${i2}th`},formatCalls=(spy,msg,actualCall)=>(spy.mock.calls&&(msg+=c().gray(`
|
|
43
|
+
`:toBeMessage}var AsymmetricMatcher3=class{constructor(sample,inverse=!1){this.sample=sample,this.inverse=inverse;}$$typeof=Symbol.for("jest.asymmetricMatcher");getMatcherContext(expect4){return {...getState(expect4||globalThis[GLOBAL_EXPECT]),equals,isNot:this.inverse,utils:{...getMatcherUtils(),diff,stringify,iterableEquality,subsetEquality}}}},StringContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){if(!isA("String",sample))throw new Error("Expected is not a string");super(sample,inverse);}asymmetricMatch(other){let result=isA("String",other)&&other.includes(this.sample);return this.inverse?!result:result}toString(){return `String${this.inverse?"Not":""}Containing`}getExpectedType(){return "string"}},Anything=class extends AsymmetricMatcher3{asymmetricMatch(other){return other!=null}toString(){return "Anything"}toAsymmetricMatcher(){return "Anything"}},ObjectContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){super(sample,inverse);}getPrototype(obj){return Object.getPrototypeOf?Object.getPrototypeOf(obj):obj.constructor.prototype===obj?null:obj.constructor.prototype}hasProperty(obj,property){return obj?Object.prototype.hasOwnProperty.call(obj,property)?!0:this.hasProperty(this.getPrototype(obj),property):!1}asymmetricMatch(other){if(typeof this.sample!="object")throw new TypeError(`You must provide an object to ${this.toString()}, not '${typeof this.sample}'.`);let result=!0;for(let property in this.sample)if(!this.hasProperty(other,property)||!equals(this.sample[property],other[property])){result=!1;break}return this.inverse?!result:result}toString(){return `Object${this.inverse?"Not":""}Containing`}getExpectedType(){return "object"}},ArrayContaining=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){super(sample,inverse);}asymmetricMatch(other){if(!Array.isArray(this.sample))throw new TypeError(`You must provide an array to ${this.toString()}, not '${typeof this.sample}'.`);let result=this.sample.length===0||Array.isArray(other)&&this.sample.every(item=>other.some(another=>equals(item,another)));return this.inverse?!result:result}toString(){return `Array${this.inverse?"Not":""}Containing`}getExpectedType(){return "array"}},Any=class extends AsymmetricMatcher3{constructor(sample){if(typeof sample>"u")throw new TypeError("any() expects to be passed a constructor function. Please pass one or use anything() to match any object.");super(sample);}fnNameFor(func){if(func.name)return func.name;let matches=Function.prototype.toString.call(func).match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/);return matches?matches[1]:"<anonymous>"}asymmetricMatch(other){return this.sample===String?typeof other=="string"||other instanceof String:this.sample===Number?typeof other=="number"||other instanceof Number:this.sample===Function?typeof other=="function"||other instanceof Function:this.sample===Boolean?typeof other=="boolean"||other instanceof Boolean:this.sample===BigInt?typeof other=="bigint"||other instanceof BigInt:this.sample===Symbol?typeof other=="symbol"||other instanceof Symbol:this.sample===Object?typeof other=="object":other instanceof this.sample}toString(){return "Any"}getExpectedType(){return this.sample===String?"string":this.sample===Number?"number":this.sample===Function?"function":this.sample===Object?"object":this.sample===Boolean?"boolean":this.fnNameFor(this.sample)}toAsymmetricMatcher(){return `Any<${this.fnNameFor(this.sample)}>`}},StringMatching=class extends AsymmetricMatcher3{constructor(sample,inverse=!1){if(!isA("String",sample)&&!isA("RegExp",sample))throw new Error("Expected is not a String or a RegExp");super(new RegExp(sample),inverse);}asymmetricMatch(other){let result=isA("String",other)&&this.sample.test(other);return this.inverse?!result:result}toString(){return `String${this.inverse?"Not":""}Matching`}getExpectedType(){return "string"}},JestAsymmetricMatchers=(chai3,utils)=>{utils.addMethod(chai3.expect,"anything",()=>new Anything),utils.addMethod(chai3.expect,"any",expected=>new Any(expected)),utils.addMethod(chai3.expect,"stringContaining",expected=>new StringContaining(expected)),utils.addMethod(chai3.expect,"objectContaining",expected=>new ObjectContaining(expected)),utils.addMethod(chai3.expect,"arrayContaining",expected=>new ArrayContaining(expected)),utils.addMethod(chai3.expect,"stringMatching",expected=>new StringMatching(expected)),chai3.expect.not={stringContaining:expected=>new StringContaining(expected,!0),objectContaining:expected=>new ObjectContaining(expected,!0),arrayContaining:expected=>new ArrayContaining(expected,!0),stringMatching:expected=>new StringMatching(expected,!0)};};function recordAsyncExpect(test,promise){return test&&promise instanceof Promise&&(promise=promise.finally(()=>{let index=test.promises.indexOf(promise);index!==-1&&test.promises.splice(index,1);}),test.promises||(test.promises=[]),test.promises.push(promise)),promise}function wrapSoft(utils,fn2){return function(...args){var _a;let test=utils.flag(this,"vitest-test");if(!(test?.context._local?test.context.expect.getState():getState(globalThis[GLOBAL_EXPECT])).soft)return fn2.apply(this,args);if(!test)throw new Error("expect.soft() can only be used inside a test");try{return fn2.apply(this,args)}catch(err){test.result||(test.result={state:"fail"}),test.result.state="fail",(_a=test.result).errors||(_a.errors=[]),test.result.errors.push(processError(err));}}}var JestChaiExpect=(chai3,utils)=>{let{AssertionError}=chai3,c=()=>getColors();function def(name,fn2){let addMethod=n=>{let softWrapper=wrapSoft(utils,fn2);utils.addMethod(chai3.Assertion.prototype,n,softWrapper),utils.addMethod(globalThis[JEST_MATCHERS_OBJECT].matchers,n,softWrapper);};Array.isArray(name)?name.forEach(n=>addMethod(n)):addMethod(name);}["throw","throws","Throw"].forEach(m2=>{utils.overwriteMethod(chai3.Assertion.prototype,m2,_super=>function(...args){let promise=utils.flag(this,"promise"),object=utils.flag(this,"object"),isNot=utils.flag(this,"negate");if(promise==="rejects")utils.flag(this,"object",()=>{throw object});else if(promise==="resolves"&&typeof object!="function"){if(isNot)return;{let message=utils.flag(this,"message")||"expected promise to throw an error, but it didn't",error={showDiff:!1};throw new AssertionError(message,error,utils.flag(this,"ssfi"))}}_super.apply(this,args);});}),def("withTest",function(test){return utils.flag(this,"vitest-test",test),this}),def("toEqual",function(expected){let actual=utils.flag(this,"object"),equal=equals(actual,expected,[iterableEquality]);return this.assert(equal,"expected #{this} to deeply equal #{exp}","expected #{this} to not deeply equal #{exp}",expected,actual)}),def("toStrictEqual",function(expected){let obj=utils.flag(this,"object"),equal=equals(obj,expected,[iterableEquality,typeEquality,sparseArrayEquality,arrayBufferEquality],!0);return this.assert(equal,"expected #{this} to strictly equal #{exp}","expected #{this} to not strictly equal #{exp}",expected,obj)}),def("toBe",function(expected){let actual=this._obj,pass=Object.is(actual,expected),deepEqualityName="";return pass||(equals(actual,expected,[iterableEquality,typeEquality,sparseArrayEquality,arrayBufferEquality],!0)?deepEqualityName="toStrictEqual":equals(actual,expected,[iterableEquality])&&(deepEqualityName="toEqual")),this.assert(pass,generateToBeMessage(deepEqualityName),"expected #{this} not to be #{exp} // Object.is equality",expected,actual)}),def("toMatchObject",function(expected){let actual=this._obj;return this.assert(equals(actual,expected,[iterableEquality,subsetEquality]),"expected #{this} to match object #{exp}","expected #{this} to not match object #{exp}",expected,actual)}),def("toMatch",function(expected){return typeof expected=="string"?this.include(expected):this.match(expected)}),def("toContain",function(item){return this.contain(item)}),def("toContainEqual",function(expected){let obj=utils.flag(this,"object"),index=Array.from(obj).findIndex(item=>equals(item,expected));this.assert(index!==-1,"expected #{this} to deep equally contain #{exp}","expected #{this} to not deep equally contain #{exp}",expected);}),def("toBeTruthy",function(){let obj=utils.flag(this,"object");this.assert(!!obj,"expected #{this} to be truthy","expected #{this} to not be truthy",obj,!1);}),def("toBeFalsy",function(){let obj=utils.flag(this,"object");this.assert(!obj,"expected #{this} to be falsy","expected #{this} to not be falsy",obj,!1);}),def("toBeGreaterThan",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual>expected,`expected ${actual} to be greater than ${expected}`,`expected ${actual} to be not greater than ${expected}`,actual,expected,!1)}),def("toBeGreaterThanOrEqual",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual>=expected,`expected ${actual} to be greater than or equal to ${expected}`,`expected ${actual} to be not greater than or equal to ${expected}`,actual,expected,!1)}),def("toBeLessThan",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual<expected,`expected ${actual} to be less than ${expected}`,`expected ${actual} to be not less than ${expected}`,actual,expected,!1)}),def("toBeLessThanOrEqual",function(expected){let actual=this._obj;return assertTypes(actual,"actual",["number","bigint"]),assertTypes(expected,"expected",["number","bigint"]),this.assert(actual<=expected,`expected ${actual} to be less than or equal to ${expected}`,`expected ${actual} to be not less than or equal to ${expected}`,actual,expected,!1)}),def("toBeNaN",function(){return this.be.NaN}),def("toBeUndefined",function(){return this.be.undefined}),def("toBeNull",function(){return this.be.null}),def("toBeDefined",function(){let negate=utils.flag(this,"negate");return utils.flag(this,"negate",!1),negate?this.be.undefined:this.not.be.undefined}),def("toBeTypeOf",function(expected){let actual=typeof this._obj,equal=expected===actual;return this.assert(equal,"expected #{this} to be type of #{exp}","expected #{this} not to be type of #{exp}",expected,actual)}),def("toBeInstanceOf",function(obj){return this.instanceOf(obj)}),def("toHaveLength",function(length){return this.have.length(length)}),def("toHaveProperty",function(...args){Array.isArray(args[0])&&(args[0]=args[0].map(key=>String(key).replace(/([.[\]])/g,"\\$1")).join("."));let actual=this._obj,[propertyName,expected]=args,getValue=()=>Object.prototype.hasOwnProperty.call(actual,propertyName)?{value:actual[propertyName],exists:!0}:utils.getPathInfo(actual,propertyName),{value,exists}=getValue(),pass=exists&&(args.length===1||equals(expected,value)),valueString=args.length===1?"":` with value ${utils.objDisplay(expected)}`;return this.assert(pass,`expected #{this} to have property "${propertyName}"${valueString}`,`expected #{this} to not have property "${propertyName}"${valueString}`,actual)}),def("toBeCloseTo",function(received,precision=2){let expected=this._obj,pass=!1,expectedDiff=0,receivedDiff=0;return received===Number.POSITIVE_INFINITY&&expected===Number.POSITIVE_INFINITY||received===Number.NEGATIVE_INFINITY&&expected===Number.NEGATIVE_INFINITY?pass=!0:(expectedDiff=10**-precision/2,receivedDiff=Math.abs(expected-received),pass=receivedDiff<expectedDiff),this.assert(pass,`expected #{this} to be close to #{exp}, received difference is ${receivedDiff}, but expected ${expectedDiff}`,`expected #{this} to not be close to #{exp}, received difference is ${receivedDiff}, but expected ${expectedDiff}`,received,expected,!1)});let assertIsMock=assertion=>{if(!isMockFunction2(assertion._obj))throw new TypeError(`${utils.inspect(assertion._obj)} is not a spy or a call to a spy!`)},getSpy=assertion=>(assertIsMock(assertion),assertion._obj),ordinalOf=i2=>{let j=i2%10,k=i2%100;return j===1&&k!==11?`${i2}st`:j===2&&k!==12?`${i2}nd`:j===3&&k!==13?`${i2}rd`:`${i2}th`},formatCalls=(spy,msg,actualCall)=>(spy.mock.calls&&(msg+=c().gray(`
|
|
44
44
|
|
|
45
45
|
Received:
|
|
46
46
|
|
|
@@ -66,7 +66,7 @@ ${spy.mock.results.map((callReturn,i2)=>{let methodCall=c().bold(` ${ordinalOf(
|
|
|
66
66
|
`)}`),msg+=c().gray(`
|
|
67
67
|
|
|
68
68
|
Number of calls: ${c().bold(spy.mock.calls.length)}
|
|
69
|
-
`),msg);def(["toHaveBeenCalledTimes","toBeCalledTimes"],function(number){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length;return this.assert(callCount===number,`expected "${spyName}" to be called #{exp} times, but got ${callCount} times`,`expected "${spyName}" to not be called #{exp} times`,number,callCount,!1)}),def("toHaveBeenCalledOnce",function(){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length;return this.assert(callCount===1,`expected "${spyName}" to be called once, but got ${callCount} times`,`expected "${spyName}" to not be called once`,1,callCount,!1)}),def(["toHaveBeenCalled","toBeCalled"],function(){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length,called=callCount>0,isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[called,`expected "${spyName}" to be called at least once`,`expected "${spyName}" to not be called at all, but actually been called ${callCount} times`,!0,called]);if(called&&isNot&&(msg=formatCalls(spy,msg)),called&&isNot||!called&&!isNot){let err=new Error(msg);throw err.name="AssertionError",err}}),def(["toHaveBeenCalledWith","toBeCalledWith"],function(...args){let spy=getSpy(this),spyName=spy.getMockName(),pass=spy.mock.calls.some(callArg=>equals(callArg,args,[iterableEquality])),isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[pass,`expected "${spyName}" to be called with arguments: #{exp}`,`expected "${spyName}" to not be called with arguments: #{exp}`,args]);if(pass&&isNot||!pass&&!isNot){msg=formatCalls(spy,msg,args);let err=new Error(msg);throw err.name="AssertionError",err}}),def(["toHaveBeenNthCalledWith","nthCalledWith"],function(times,...args){let spy=getSpy(this),spyName=spy.getMockName(),nthCall=spy.mock.calls[times-1];this.assert(equals(nthCall,args,[iterableEquality]),`expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}`,`expected ${ordinalOf(times)} "${spyName}" call to not have been called with #{exp}`,args,nthCall);}),def(["toHaveBeenLastCalledWith","lastCalledWith"],function(...args){let spy=getSpy(this),spyName=spy.getMockName(),lastCall=spy.mock.calls[spy.mock.calls.length-1];this.assert(equals(lastCall,args,[iterableEquality]),`expected last "${spyName}" call to have been called with #{exp}`,`expected last "${spyName}" call to not have been called with #{exp}`,args,lastCall);}),def(["toThrow","toThrowError"],function(expected){if(typeof expected=="string"||typeof expected>"u"||expected instanceof RegExp)return this.throws(expected);let obj=this._obj,promise=utils.flag(this,"promise"),isNot=utils.flag(this,"negate"),thrown=null;if(promise==="rejects")thrown=obj;else if(promise==="resolves"&&typeof obj!="function"){if(isNot)return;{let message=utils.flag(this,"message")||"expected promise to throw an error, but it didn't",error={showDiff:!1};throw new AssertionError(message,error,utils.flag(this,"ssfi"))}}else try{obj();}catch(err){thrown=err;}if(typeof expected=="function"){let name=expected.name||expected.prototype.constructor.name;return this.assert(thrown&&thrown instanceof expected,`expected error to be instance of ${name}`,`expected error not to be instance of ${name}`,expected,thrown,!1)}if(expected instanceof Error)return this.assert(thrown&&expected.message===thrown.message,`expected error to have message: ${expected.message}`,`expected error not to have message: ${expected.message}`,expected.message,thrown&&thrown.message);if(typeof expected=="object"&&"asymmetricMatch"in expected&&typeof expected.asymmetricMatch=="function"){let matcher=expected;return this.assert(thrown&&matcher.asymmetricMatch(thrown),"expected error to match asymmetric matcher","expected error not to match asymmetric matcher",matcher.toString(),thrown,!1)}throw new Error(`"toThrow" expects string, RegExp, function, Error instance or asymmetric matcher, got "${typeof expected}"`)}),def(["toHaveReturned","toReturn"],function(){let spy=getSpy(this),spyName=spy.getMockName(),calledAndNotThrew=spy.mock.calls.length>0&&spy.mock.results.some(({type})=>type!=="throw");this.assert(calledAndNotThrew,`expected "${spyName}" to be successfully called at least once`,`expected "${spyName}" to not be successfully called`,calledAndNotThrew,!calledAndNotThrew,!1);}),def(["toHaveReturnedTimes","toReturnTimes"],function(times){let spy=getSpy(this),spyName=spy.getMockName(),successfulReturns=spy.mock.results.reduce((success,{type})=>type==="throw"?success:++success,0);this.assert(successfulReturns===times,`expected "${spyName}" to be successfully called ${times} times`,`expected "${spyName}" to not be successfully called ${times} times`,`expected number of returns: ${times}`,`received number of returns: ${successfulReturns}`,!1);}),def(["toHaveReturnedWith","toReturnWith"],function(value){let spy=getSpy(this),spyName=spy.getMockName(),pass=spy.mock.results.some(({type,value:result})=>type==="return"&&equals(value,result)),isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[pass,`expected "${spyName}" to return with: #{exp} at least once`,`expected "${spyName}" to not return with: #{exp}`,value]);if(pass&&isNot||!pass&&!isNot){msg=formatReturns(spy,msg,value);let err=new Error(msg);throw err.name="AssertionError",err}}),def(["toHaveLastReturnedWith","lastReturnedWith"],function(value){let spy=getSpy(this),spyName=spy.getMockName(),{value:lastResult}=spy.mock.results[spy.mock.results.length-1],pass=equals(lastResult,value);this.assert(pass,`expected last "${spyName}" call to return #{exp}`,`expected last "${spyName}" call to not return #{exp}`,value,lastResult);}),def(["toHaveNthReturnedWith","nthReturnedWith"],function(nthCall,value){let spy=getSpy(this),spyName=spy.getMockName(),isNot=utils.flag(this,"negate"),{type:callType,value:callResult}=spy.mock.results[nthCall-1],ordinalCall=`${ordinalOf(nthCall)} call`;!isNot&&callType==="throw"&&chai3.assert.fail(`expected ${ordinalCall} to return #{exp}, but instead it threw an error`);let nthCallReturn=equals(callResult,value);this.assert(nthCallReturn,`expected ${ordinalCall} "${spyName}" call to return #{exp}`,`expected ${ordinalCall} "${spyName}" call to not return #{exp}`,value,callResult);}),def("toSatisfy",function(matcher,message){return this.be.satisfy(matcher,message)}),utils.addProperty(chai3.Assertion.prototype,"resolves",function(){utils.flag(this,"promise","resolves"),utils.flag(this,"error",new Error("resolves"));let test=utils.flag(this,"vitest-test"),obj=utils.flag(this,"object");if(typeof obj?.then!="function")throw new TypeError(`You must provide a Promise to expect() when using .resolves, not '${typeof obj}'.`);let proxy=new Proxy(this,{get:(target,key,receiver)=>{let result=Reflect.get(target,key,receiver);return typeof result!="function"?result instanceof chai3.Assertion?proxy:result:async(...args)=>{let promise=obj.then(value=>(utils.flag(this,"object",value),result.call(this,...args)),err=>{throw new Error(`promise rejected "${String(err)}" instead of resolving`)});return recordAsyncExpect(test,promise)}}});return proxy}),utils.addProperty(chai3.Assertion.prototype,"rejects",function(){utils.flag(this,"promise","rejects"),utils.flag(this,"error",new Error("rejects"));let test=utils.flag(this,"vitest-test"),obj=utils.flag(this,"object"),wrapper=typeof obj=="function"?obj():obj;if(typeof wrapper?.then!="function")throw new TypeError(`You must provide a Promise to expect() when using .rejects, not '${typeof wrapper}'.`);let proxy=new Proxy(this,{get:(target,key,receiver)=>{let result=Reflect.get(target,key,receiver);return typeof result!="function"?result instanceof chai3.Assertion?proxy:result:async(...args)=>{let promise=wrapper.then(value=>{throw new Error(`promise resolved "${String(value)}" instead of rejecting`)},err=>(utils.flag(this,"object",err),result.call(this,...args)));return recordAsyncExpect(test,promise)}}});return proxy});};function getMatcherState(assertion,expect4){let obj=assertion._obj,isNot=util.flag(assertion,"negate"),promise=util.flag(assertion,"promise")||"",jestUtils={...getMatcherUtils(),diff,stringify,iterableEquality,subsetEquality};return {state:{...getState(expect4),isNot,utils:jestUtils,promise,equals,suppressedErrors:[]},isNot,obj}}var JestExtendError=class extends Error{constructor(message,actual,expected){super(message),this.actual=actual,this.expected=expected;}};function JestExtendPlugin(expect4,matchers2){return (c,utils)=>{Object.entries(matchers2).forEach(([expectAssertionName,expectAssertion])=>{function expectWrapper(...args){let{state,isNot,obj}=getMatcherState(this,expect4),result=expectAssertion.call(state,obj,...args);if(result&&typeof result=="object"&&result instanceof Promise)return result.then(({pass:pass2,message:message2,actual:actual2,expected:expected2})=>{if(pass2&&isNot||!pass2&&!isNot)throw new JestExtendError(message2(),actual2,expected2)});let{pass,message,actual,expected}=result;if(pass&&isNot||!pass&&!isNot)throw new JestExtendError(message(),actual,expected)}let softWrapper=wrapSoft(utils,expectWrapper);utils.addMethod(globalThis[JEST_MATCHERS_OBJECT].matchers,expectAssertionName,softWrapper),utils.addMethod(c.Assertion.prototype,expectAssertionName,softWrapper);class CustomMatcher extends AsymmetricMatcher3{constructor(inverse=!1,...sample){super(sample,inverse);}asymmetricMatch(other){let{pass}=expectAssertion.call(this.getMatcherContext(expect4),other,...this.sample);return this.inverse?!pass:pass}toString(){return `${this.inverse?"not.":""}${expectAssertionName}`}getExpectedType(){return "any"}toAsymmetricMatcher(){return `${this.toString()}<${this.sample.map(String).join(", ")}>`}}Object.defineProperty(expect4,expectAssertionName,{configurable:!0,enumerable:!0,value:(...sample)=>new CustomMatcher(!1,...sample),writable:!0}),Object.defineProperty(expect4.not,expectAssertionName,{configurable:!0,enumerable:!0,value:(...sample)=>new CustomMatcher(!0,...sample),writable:!0});});}}var JestExtend=(chai3,utils)=>{utils.addMethod(chai3.expect,"extend",(expect4,expects)=>{chai3.use(JestExtendPlugin(expect4,expects));});};function createExpect(){chai.use(JestExtend),chai.use(JestChaiExpect),chai.use(JestAsymmetricMatchers);let expect4=(value,message)=>{let{assertionCalls}=getState(expect4);return setState({assertionCalls:assertionCalls+1,soft:!1},expect4),chai.expect(value,message)};Object.assign(expect4,chai.expect),expect4.getState=()=>getState(expect4),expect4.setState=state=>setState(state,expect4),expect4.extend=expects=>chai.expect.extend(expect4,expects),expect4.soft=(...args)=>{let assert2=expect4(...args);return expect4.setState({soft:!0}),assert2},expect4.unreachable=message=>{chai.assert.fail(`expected${message?` "${message}" `:" "}not to be reached`);};function assertions(expected){let errorGen=()=>new Error(`expected number of assertions to be ${expected}, but got ${expect4.getState().assertionCalls}`);"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen});}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(error,hasAssertions),expect4.setState({isExpectingAssertions:!0,isExpectingAssertionsError:error});}return setState({assertionCalls:0,isExpectingAssertions:!1,isExpectingAssertionsError:null,expectedAssertionsNumber:null,expectedAssertionsNumberErrorGen:null},expect4),chai.util.addMethod(expect4,"assertions",assertions),chai.util.addMethod(expect4,"hasAssertions",hasAssertions),expect4.extend(matchers),expect4}var expect2=createExpect();Object.defineProperty(globalThis,GLOBAL_EXPECT,{value:expect2,writable:!0,configurable:!0});var testingLibrary=instrument({...domTestingLibrary},{intercept:(method,path)=>path[0]==="fireEvent"||method.startsWith("find")||method.startsWith("waitFor")});testingLibrary.screen=new Proxy(testingLibrary.screen,{get(target,prop,receiver){return once.warn(dedent`
|
|
69
|
+
`),msg);def(["toHaveBeenCalledTimes","toBeCalledTimes"],function(number){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length;return this.assert(callCount===number,`expected "${spyName}" to be called #{exp} times, but got ${callCount} times`,`expected "${spyName}" to not be called #{exp} times`,number,callCount,!1)}),def("toHaveBeenCalledOnce",function(){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length;return this.assert(callCount===1,`expected "${spyName}" to be called once, but got ${callCount} times`,`expected "${spyName}" to not be called once`,1,callCount,!1)}),def(["toHaveBeenCalled","toBeCalled"],function(){let spy=getSpy(this),spyName=spy.getMockName(),callCount=spy.mock.calls.length,called=callCount>0,isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[called,`expected "${spyName}" to be called at least once`,`expected "${spyName}" to not be called at all, but actually been called ${callCount} times`,!0,called]);if(called&&isNot&&(msg=formatCalls(spy,msg)),called&&isNot||!called&&!isNot)throw new AssertionError(msg)}),def(["toHaveBeenCalledWith","toBeCalledWith"],function(...args){let spy=getSpy(this),spyName=spy.getMockName(),pass=spy.mock.calls.some(callArg=>equals(callArg,args,[iterableEquality])),isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[pass,`expected "${spyName}" to be called with arguments: #{exp}`,`expected "${spyName}" to not be called with arguments: #{exp}`,args]);if(pass&&isNot||!pass&&!isNot)throw new AssertionError(formatCalls(spy,msg,args))}),def(["toHaveBeenNthCalledWith","nthCalledWith"],function(times,...args){let spy=getSpy(this),spyName=spy.getMockName(),nthCall=spy.mock.calls[times-1];this.assert(equals(nthCall,args,[iterableEquality]),`expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}`,`expected ${ordinalOf(times)} "${spyName}" call to not have been called with #{exp}`,args,nthCall);}),def(["toHaveBeenLastCalledWith","lastCalledWith"],function(...args){let spy=getSpy(this),spyName=spy.getMockName(),lastCall=spy.mock.calls[spy.mock.calls.length-1];this.assert(equals(lastCall,args,[iterableEquality]),`expected last "${spyName}" call to have been called with #{exp}`,`expected last "${spyName}" call to not have been called with #{exp}`,args,lastCall);}),def(["toThrow","toThrowError"],function(expected){if(typeof expected=="string"||typeof expected>"u"||expected instanceof RegExp)return this.throws(expected);let obj=this._obj,promise=utils.flag(this,"promise"),isNot=utils.flag(this,"negate"),thrown=null;if(promise==="rejects")thrown=obj;else if(promise==="resolves"&&typeof obj!="function"){if(isNot)return;{let message=utils.flag(this,"message")||"expected promise to throw an error, but it didn't",error={showDiff:!1};throw new AssertionError(message,error,utils.flag(this,"ssfi"))}}else {let isThrow=!1;try{obj();}catch(err){isThrow=!0,thrown=err;}if(!isThrow&&!isNot){let message=utils.flag(this,"message")||"expected function to throw an error, but it didn't",error={showDiff:!1};throw new AssertionError(message,error,utils.flag(this,"ssfi"))}}if(typeof expected=="function"){let name=expected.name||expected.prototype.constructor.name;return this.assert(thrown&&thrown instanceof expected,`expected error to be instance of ${name}`,`expected error not to be instance of ${name}`,expected,thrown,!1)}if(expected instanceof Error)return this.assert(thrown&&expected.message===thrown.message,`expected error to have message: ${expected.message}`,`expected error not to have message: ${expected.message}`,expected.message,thrown&&thrown.message);if(typeof expected=="object"&&"asymmetricMatch"in expected&&typeof expected.asymmetricMatch=="function"){let matcher=expected;return this.assert(thrown&&matcher.asymmetricMatch(thrown),"expected error to match asymmetric matcher","expected error not to match asymmetric matcher",matcher.toString(),thrown,!1)}throw new Error(`"toThrow" expects string, RegExp, function, Error instance or asymmetric matcher, got "${typeof expected}"`)}),def(["toHaveReturned","toReturn"],function(){let spy=getSpy(this),spyName=spy.getMockName(),calledAndNotThrew=spy.mock.calls.length>0&&spy.mock.results.some(({type})=>type!=="throw");this.assert(calledAndNotThrew,`expected "${spyName}" to be successfully called at least once`,`expected "${spyName}" to not be successfully called`,calledAndNotThrew,!calledAndNotThrew,!1);}),def(["toHaveReturnedTimes","toReturnTimes"],function(times){let spy=getSpy(this),spyName=spy.getMockName(),successfulReturns=spy.mock.results.reduce((success,{type})=>type==="throw"?success:++success,0);this.assert(successfulReturns===times,`expected "${spyName}" to be successfully called ${times} times`,`expected "${spyName}" to not be successfully called ${times} times`,`expected number of returns: ${times}`,`received number of returns: ${successfulReturns}`,!1);}),def(["toHaveReturnedWith","toReturnWith"],function(value){let spy=getSpy(this),spyName=spy.getMockName(),pass=spy.mock.results.some(({type,value:result})=>type==="return"&&equals(value,result)),isNot=utils.flag(this,"negate"),msg=utils.getMessage(this,[pass,`expected "${spyName}" to return with: #{exp} at least once`,`expected "${spyName}" to not return with: #{exp}`,value]);if(pass&&isNot||!pass&&!isNot)throw new AssertionError(formatReturns(spy,msg,value))}),def(["toHaveLastReturnedWith","lastReturnedWith"],function(value){let spy=getSpy(this),spyName=spy.getMockName(),{value:lastResult}=spy.mock.results[spy.mock.results.length-1],pass=equals(lastResult,value);this.assert(pass,`expected last "${spyName}" call to return #{exp}`,`expected last "${spyName}" call to not return #{exp}`,value,lastResult);}),def(["toHaveNthReturnedWith","nthReturnedWith"],function(nthCall,value){let spy=getSpy(this),spyName=spy.getMockName(),isNot=utils.flag(this,"negate"),{type:callType,value:callResult}=spy.mock.results[nthCall-1],ordinalCall=`${ordinalOf(nthCall)} call`;!isNot&&callType==="throw"&&chai3.assert.fail(`expected ${ordinalCall} to return #{exp}, but instead it threw an error`);let nthCallReturn=equals(callResult,value);this.assert(nthCallReturn,`expected ${ordinalCall} "${spyName}" call to return #{exp}`,`expected ${ordinalCall} "${spyName}" call to not return #{exp}`,value,callResult);}),def("toSatisfy",function(matcher,message){return this.be.satisfy(matcher,message)}),utils.addProperty(chai3.Assertion.prototype,"resolves",function(){let error=new Error("resolves");utils.flag(this,"promise","resolves"),utils.flag(this,"error",error);let test=utils.flag(this,"vitest-test"),obj=utils.flag(this,"object");if(typeof obj?.then!="function")throw new TypeError(`You must provide a Promise to expect() when using .resolves, not '${typeof obj}'.`);let proxy=new Proxy(this,{get:(target,key,receiver)=>{let result=Reflect.get(target,key,receiver);return typeof result!="function"?result instanceof chai3.Assertion?proxy:result:async(...args)=>{let promise=obj.then(value=>(utils.flag(this,"object",value),result.call(this,...args)),err=>{let _error=new AssertionError(`promise rejected "${utils.inspect(err)}" instead of resolving`,{showDiff:!1});throw _error.stack=error.stack.replace(error.message,_error.message),_error});return recordAsyncExpect(test,promise)}}});return proxy}),utils.addProperty(chai3.Assertion.prototype,"rejects",function(){let error=new Error("rejects");utils.flag(this,"promise","rejects"),utils.flag(this,"error",error);let test=utils.flag(this,"vitest-test"),obj=utils.flag(this,"object"),wrapper=typeof obj=="function"?obj():obj;if(typeof wrapper?.then!="function")throw new TypeError(`You must provide a Promise to expect() when using .rejects, not '${typeof wrapper}'.`);let proxy=new Proxy(this,{get:(target,key,receiver)=>{let result=Reflect.get(target,key,receiver);return typeof result!="function"?result instanceof chai3.Assertion?proxy:result:async(...args)=>{let promise=wrapper.then(value=>{let _error=new AssertionError(`promise resolved "${utils.inspect(value)}" instead of rejecting`,{showDiff:!1});throw _error.stack=error.stack.replace(error.message,_error.message),_error},err=>(utils.flag(this,"object",err),result.call(this,...args)));return recordAsyncExpect(test,promise)}}});return proxy});};function getMatcherState(assertion,expect4){let obj=assertion._obj,isNot=util.flag(assertion,"negate"),promise=util.flag(assertion,"promise")||"",jestUtils={...getMatcherUtils(),diff,stringify,iterableEquality,subsetEquality};return {state:{...getState(expect4),isNot,utils:jestUtils,promise,equals,suppressedErrors:[]},isNot,obj}}var JestExtendError=class extends Error{constructor(message,actual,expected){super(message),this.actual=actual,this.expected=expected;}};function JestExtendPlugin(expect4,matchers2){return (c,utils)=>{Object.entries(matchers2).forEach(([expectAssertionName,expectAssertion])=>{function expectWrapper(...args){let{state,isNot,obj}=getMatcherState(this,expect4),result=expectAssertion.call(state,obj,...args);if(result&&typeof result=="object"&&result instanceof Promise)return result.then(({pass:pass2,message:message2,actual:actual2,expected:expected2})=>{if(pass2&&isNot||!pass2&&!isNot)throw new JestExtendError(message2(),actual2,expected2)});let{pass,message,actual,expected}=result;if(pass&&isNot||!pass&&!isNot)throw new JestExtendError(message(),actual,expected)}let softWrapper=wrapSoft(utils,expectWrapper);utils.addMethod(globalThis[JEST_MATCHERS_OBJECT].matchers,expectAssertionName,softWrapper),utils.addMethod(c.Assertion.prototype,expectAssertionName,softWrapper);class CustomMatcher extends AsymmetricMatcher3{constructor(inverse=!1,...sample){super(sample,inverse);}asymmetricMatch(other){let{pass}=expectAssertion.call(this.getMatcherContext(expect4),other,...this.sample);return this.inverse?!pass:pass}toString(){return `${this.inverse?"not.":""}${expectAssertionName}`}getExpectedType(){return "any"}toAsymmetricMatcher(){return `${this.toString()}<${this.sample.map(String).join(", ")}>`}}Object.defineProperty(expect4,expectAssertionName,{configurable:!0,enumerable:!0,value:(...sample)=>new CustomMatcher(!1,...sample),writable:!0}),Object.defineProperty(expect4.not,expectAssertionName,{configurable:!0,enumerable:!0,value:(...sample)=>new CustomMatcher(!0,...sample),writable:!0});});}}var JestExtend=(chai3,utils)=>{utils.addMethod(chai3.expect,"extend",(expect4,expects)=>{chai3.use(JestExtendPlugin(expect4,expects));});};function createExpect(){chai.use(JestExtend),chai.use(JestChaiExpect),chai.use(JestAsymmetricMatchers);let expect4=(value,message)=>{let{assertionCalls}=getState(expect4);return setState({assertionCalls:assertionCalls+1,soft:!1},expect4),chai.expect(value,message)};Object.assign(expect4,chai.expect),expect4.getState=()=>getState(expect4),expect4.setState=state=>setState(state,expect4),expect4.extend=expects=>chai.expect.extend(expect4,expects),expect4.soft=(...args)=>{let assert2=expect4(...args);return expect4.setState({soft:!0}),assert2},expect4.unreachable=message=>{chai.assert.fail(`expected${message?` "${message}" `:" "}not to be reached`);};function assertions(expected){let errorGen=()=>new Error(`expected number of assertions to be ${expected}, but got ${expect4.getState().assertionCalls}`);"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen});}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(error,hasAssertions),expect4.setState({isExpectingAssertions:!0,isExpectingAssertionsError:error});}return setState({assertionCalls:0,isExpectingAssertions:!1,isExpectingAssertionsError:null,expectedAssertionsNumber:null,expectedAssertionsNumberErrorGen:null},expect4),chai.util.addMethod(expect4,"assertions",assertions),chai.util.addMethod(expect4,"hasAssertions",hasAssertions),expect4.extend(matchers),expect4}var expect2=createExpect();Object.defineProperty(globalThis,GLOBAL_EXPECT,{value:expect2,writable:!0,configurable:!0});var testingLibrary=instrument({...domTestingLibrary},{intercept:(method,path)=>path[0]==="fireEvent"||method.startsWith("find")||method.startsWith("waitFor")});testingLibrary.screen=new Proxy(testingLibrary.screen,{get(target,prop,receiver){return once.warn(dedent`
|
|
70
70
|
You are using Testing Library's \`screen\` object. Use \`within(canvasElement)\` instead.
|
|
71
71
|
More info: https://storybook.js.org/docs/react/essentials/interactions
|
|
72
72
|
`),Reflect.get(target,prop,receiver)}});var {buildQueries,configure,createEvent,fireEvent,findAllByAltText,findAllByDisplayValue,findAllByLabelText,findAllByPlaceholderText,findAllByRole,findAllByTestId,findAllByText,findAllByTitle,findByAltText,findByDisplayValue,findByLabelText,findByPlaceholderText,findByRole,findByTestId,findByText,findByTitle,getAllByAltText,getAllByDisplayValue,getAllByLabelText,getAllByPlaceholderText,getAllByRole,getAllByTestId,getAllByText,getAllByTitle,getByAltText,getByDisplayValue,getByLabelText,getByPlaceholderText,getByRole,getByTestId,getByText,getByTitle,getConfig,getDefaultNormalizer,getElementError,getNodeText,getQueriesForElement,getRoles,getSuggestedQuery,isInaccessible,logDOM,logRoles,prettyDOM,queries,queryAllByAltText,queryAllByAttribute,queryAllByDisplayValue,queryAllByLabelText,queryAllByPlaceholderText,queryAllByRole,queryAllByTestId,queryAllByText,queryAllByTitle,queryByAltText,queryByAttribute,queryByDisplayValue,queryByLabelText,queryByPlaceholderText,queryByRole,queryByTestId,queryByText,queryByTitle,queryHelpers,screen,waitFor,waitForElementToBeRemoved,within,prettyFormat}=testingLibrary,{userEvent}=instrument({userEvent:_userEvent},{intercept:!0});var channel=addons.getChannel();channel.on(FORCE_REMOUNT,()=>spies.forEach(mock=>mock.mockClear()));channel.on(STORY_RENDER_PHASE_CHANGED,({newPhase})=>{newPhase==="loading"&&spies.forEach(mock=>mock.mockClear());});var {expect:expect3}=instrument({expect:expect2},{getKeys:(obj,depth)=>{let privateApi=["assert","__methods","__flags"];if(obj.constructor===chai__default.Assertion){let keys2=Object.keys(Object.getPrototypeOf(obj)).filter(it=>!privateApi.includes(it));return depth>2?keys2:[...keys2,"not"]}return Object.keys(obj)},intercept:method=>method!=="expect"});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/test",
|
|
3
|
-
"version": "0.0.0-pr-23888-sha-
|
|
3
|
+
"version": "0.0.0-pr-23888-sha-8657c59a",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"prep": "../../../scripts/prepare/bundle.ts"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@storybook/client-logger": "0.0.0-pr-23888-sha-
|
|
47
|
-
"@storybook/core-events": "0.0.0-pr-23888-sha-
|
|
48
|
-
"@storybook/instrumenter": "0.0.0-pr-23888-sha-
|
|
49
|
-
"@storybook/preview-api": "0.0.0-pr-23888-sha-
|
|
46
|
+
"@storybook/client-logger": "0.0.0-pr-23888-sha-8657c59a",
|
|
47
|
+
"@storybook/core-events": "0.0.0-pr-23888-sha-8657c59a",
|
|
48
|
+
"@storybook/instrumenter": "0.0.0-pr-23888-sha-8657c59a",
|
|
49
|
+
"@storybook/preview-api": "0.0.0-pr-23888-sha-8657c59a",
|
|
50
50
|
"@testing-library/dom": "^9.3.1",
|
|
51
51
|
"@testing-library/jest-dom": "^6.1.3",
|
|
52
52
|
"@testing-library/user-event": "^14.4.3",
|