Add comprehensive development roadmap via GitHub Issues
Created 10 detailed GitHub issues covering: - Project activation and management UI (#1-2) - Worker node coordination and visualization (#3-4) - Automated GitHub repository scanning (#5) - Intelligent model-to-issue matching (#6) - Multi-model task execution system (#7) - N8N workflow integration (#8) - Hive-Bzzz P2P bridge (#9) - Peer assistance protocol (#10) Each issue includes detailed specifications, acceptance criteria, technical implementation notes, and dependency mapping. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
21
frontend/node_modules/@vitest/spy/LICENSE
generated
vendored
Normal file
21
frontend/node_modules/@vitest/spy/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-Present Vitest Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
3
frontend/node_modules/@vitest/spy/README.md
generated
vendored
Normal file
3
frontend/node_modules/@vitest/spy/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# @vitest/spy
|
||||
|
||||
Lightweight Jest compatible spy implementation.
|
||||
356
frontend/node_modules/@vitest/spy/dist/index.d.ts
generated
vendored
Normal file
356
frontend/node_modules/@vitest/spy/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,356 @@
|
||||
interface MockResultReturn<T> {
|
||||
type: "return";
|
||||
/**
|
||||
* The value that was returned from the function. If function returned a Promise, then this will be a resolved value.
|
||||
*/
|
||||
value: T;
|
||||
}
|
||||
interface MockResultIncomplete {
|
||||
type: "incomplete";
|
||||
value: undefined;
|
||||
}
|
||||
interface MockResultThrow {
|
||||
type: "throw";
|
||||
/**
|
||||
* An error that was thrown during function execution.
|
||||
*/
|
||||
value: any;
|
||||
}
|
||||
interface MockSettledResultFulfilled<T> {
|
||||
type: "fulfilled";
|
||||
value: T;
|
||||
}
|
||||
interface MockSettledResultRejected {
|
||||
type: "rejected";
|
||||
value: any;
|
||||
}
|
||||
type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
|
||||
type MockSettledResult<T> = MockSettledResultFulfilled<T> | MockSettledResultRejected;
|
||||
interface MockContext<T extends Procedure> {
|
||||
/**
|
||||
* This is an array containing all arguments for each call. One item of the array is the arguments of that call.
|
||||
*
|
||||
* @see https://vitest.dev/api/mock#mock-calls
|
||||
* @example
|
||||
* const fn = vi.fn()
|
||||
*
|
||||
* fn('arg1', 'arg2')
|
||||
* fn('arg3')
|
||||
*
|
||||
* fn.mock.calls === [
|
||||
* ['arg1', 'arg2'], // first call
|
||||
* ['arg3'], // second call
|
||||
* ]
|
||||
*/
|
||||
calls: Parameters<T>[];
|
||||
/**
|
||||
* This is an array containing all instances that were instantiated when mock was called with a `new` keyword. Note that this is an actual context (`this`) of the function, not a return value.
|
||||
* @see https://vitest.dev/api/mock#mock-instances
|
||||
*/
|
||||
instances: ReturnType<T>[];
|
||||
/**
|
||||
* An array of `this` values that were used during each call to the mock function.
|
||||
* @see https://vitest.dev/api/mock#mock-contexts
|
||||
*/
|
||||
contexts: ThisParameterType<T>[];
|
||||
/**
|
||||
* The order of mock's execution. This returns an array of numbers which are shared between all defined mocks.
|
||||
*
|
||||
* @see https://vitest.dev/api/mock#mock-invocationcallorder
|
||||
* @example
|
||||
* const fn1 = vi.fn()
|
||||
* const fn2 = vi.fn()
|
||||
*
|
||||
* fn1()
|
||||
* fn2()
|
||||
* fn1()
|
||||
*
|
||||
* fn1.mock.invocationCallOrder === [1, 3]
|
||||
* fn2.mock.invocationCallOrder === [2]
|
||||
*/
|
||||
invocationCallOrder: number[];
|
||||
/**
|
||||
* This is an array containing all values that were `returned` from the function.
|
||||
*
|
||||
* The `value` property contains the returned value or thrown error. If the function returned a `Promise`, then `result` will always be `'return'` even if the promise was rejected.
|
||||
*
|
||||
* @see https://vitest.dev/api/mock#mock-results
|
||||
* @example
|
||||
* const fn = vi.fn()
|
||||
* .mockReturnValueOnce('result')
|
||||
* .mockImplementationOnce(() => { throw new Error('thrown error') })
|
||||
*
|
||||
* const result = fn()
|
||||
*
|
||||
* try {
|
||||
* fn()
|
||||
* }
|
||||
* catch {}
|
||||
*
|
||||
* fn.mock.results === [
|
||||
* {
|
||||
* type: 'return',
|
||||
* value: 'result',
|
||||
* },
|
||||
* {
|
||||
* type: 'throw',
|
||||
* value: Error,
|
||||
* },
|
||||
* ]
|
||||
*/
|
||||
results: MockResult<ReturnType<T>>[];
|
||||
/**
|
||||
* An array containing all values that were `resolved` or `rejected` from the function.
|
||||
*
|
||||
* This array will be empty if the function was never resolved or rejected.
|
||||
*
|
||||
* @see https://vitest.dev/api/mock#mock-settledresults
|
||||
* @example
|
||||
* const fn = vi.fn().mockResolvedValueOnce('result')
|
||||
*
|
||||
* const result = fn()
|
||||
*
|
||||
* fn.mock.settledResults === []
|
||||
* fn.mock.results === [
|
||||
* {
|
||||
* type: 'return',
|
||||
* value: Promise<'result'>,
|
||||
* },
|
||||
* ]
|
||||
*
|
||||
* await result
|
||||
*
|
||||
* fn.mock.settledResults === [
|
||||
* {
|
||||
* type: 'fulfilled',
|
||||
* value: 'result',
|
||||
* },
|
||||
* ]
|
||||
*/
|
||||
settledResults: MockSettledResult<Awaited<ReturnType<T>>>[];
|
||||
/**
|
||||
* This contains the arguments of the last call. If spy wasn't called, will return `undefined`.
|
||||
* @see https://vitest.dev/api/mock#mock-lastcall
|
||||
*/
|
||||
lastCall: Parameters<T> | undefined;
|
||||
}
|
||||
type Procedure = (...args: any[]) => any;
|
||||
// pick a single function type from function overloads, unions, etc...
|
||||
type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
|
||||
type Methods<T> = keyof { [K in keyof T as T[K] extends Procedure ? K : never] : T[K] };
|
||||
type Properties<T> = { [K in keyof T] : T[K] extends Procedure ? never : K }[keyof T] & (string | symbol);
|
||||
type Classes<T> = { [K in keyof T] : T[K] extends new (...args: any[]) => any ? K : never }[keyof T] & (string | symbol);
|
||||
/*
|
||||
cf. https://typescript-eslint.io/rules/method-signature-style/
|
||||
|
||||
Typescript assignability is different between
|
||||
{ foo: (f: T) => U } (this is "method-signature-style")
|
||||
and
|
||||
{ foo(f: T): U }
|
||||
|
||||
Jest uses the latter for `MockInstance.mockImplementation` etc... and it allows assignment such as:
|
||||
const boolFn: Jest.Mock<() => boolean> = jest.fn<() => true>(() => true)
|
||||
*/
|
||||
/* eslint-disable ts/method-signature-style */
|
||||
interface MockInstance<T extends Procedure = Procedure> extends Disposable {
|
||||
/**
|
||||
* Use it to return the name assigned to the mock with the `.mockName(name)` method. By default, it will return `vi.fn()`.
|
||||
* @see https://vitest.dev/api/mock#getmockname
|
||||
*/
|
||||
getMockName(): string;
|
||||
/**
|
||||
* Sets the internal mock name. This is useful for identifying the mock when an assertion fails.
|
||||
* @see https://vitest.dev/api/mock#mockname
|
||||
*/
|
||||
mockName(name: string): this;
|
||||
/**
|
||||
* Current context of the mock. It stores information about all invocation calls, instances, and results.
|
||||
*/
|
||||
mock: MockContext<T>;
|
||||
/**
|
||||
* Clears all information about every call. After calling it, all properties on `.mock` will return to their initial state. This method does not reset implementations. It is useful for cleaning up mocks between different assertions.
|
||||
*
|
||||
* To automatically call this method before each test, enable the [`clearMocks`](https://vitest.dev/config/#clearmocks) setting in the configuration.
|
||||
* @see https://vitest.dev/api/mock#mockclear
|
||||
*/
|
||||
mockClear(): this;
|
||||
/**
|
||||
* Does what `mockClear` does and resets inner implementation to the original function. This also resets all "once" implementations.
|
||||
*
|
||||
* Note that resetting a mock from `vi.fn()` will set implementation to an empty function that returns `undefined`.
|
||||
* Resetting a mock from `vi.fn(impl)` will set implementation to `impl`. It is useful for completely resetting a mock to its default state.
|
||||
*
|
||||
* To automatically call this method before each test, enable the [`mockReset`](https://vitest.dev/config/#mockreset) setting in the configuration.
|
||||
* @see https://vitest.dev/api/mock#mockreset
|
||||
*/
|
||||
mockReset(): this;
|
||||
/**
|
||||
* Does what `mockReset` does and restores original descriptors of spied-on objects.
|
||||
*
|
||||
* Note that restoring mock from `vi.fn()` will set implementation to an empty function that returns `undefined`. Restoring a `vi.fn(impl)` will restore implementation to `impl`.
|
||||
* @see https://vitest.dev/api/mock#mockrestore
|
||||
*/
|
||||
mockRestore(): void;
|
||||
/**
|
||||
* Returns current permanent mock implementation if there is one.
|
||||
*
|
||||
* If mock was created with `vi.fn`, it will consider passed down method as a mock implementation.
|
||||
*
|
||||
* If mock was created with `vi.spyOn`, it will return `undefined` unless a custom implementation was provided.
|
||||
*/
|
||||
getMockImplementation(): NormalizedProcedure<T> | undefined;
|
||||
/**
|
||||
* Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function.
|
||||
* @see https://vitest.dev/api/mock#mockimplementation
|
||||
* @example
|
||||
* const increment = vi.fn().mockImplementation(count => count + 1);
|
||||
* expect(increment(3)).toBe(4);
|
||||
*/
|
||||
mockImplementation(fn: NormalizedProcedure<T>): this;
|
||||
/**
|
||||
* Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function. This method can be chained to produce different results for multiple function calls.
|
||||
*
|
||||
* When the mocked function runs out of implementations, it will invoke the default implementation set with `vi.fn(() => defaultValue)` or `.mockImplementation(() => defaultValue)` if they were called.
|
||||
* @see https://vitest.dev/api/mock#mockimplementationonce
|
||||
* @example
|
||||
* const fn = vi.fn(count => count).mockImplementationOnce(count => count + 1);
|
||||
* expect(fn(3)).toBe(4);
|
||||
* expect(fn(3)).toBe(3);
|
||||
*/
|
||||
mockImplementationOnce(fn: NormalizedProcedure<T>): this;
|
||||
/**
|
||||
* Overrides the original mock implementation temporarily while the callback is being executed.
|
||||
*
|
||||
* Note that this method takes precedence over the [`mockImplementationOnce`](https://vitest.dev/api/mock#mockimplementationonce).
|
||||
* @see https://vitest.dev/api/mock#withimplementation
|
||||
* @example
|
||||
* const myMockFn = vi.fn(() => 'original')
|
||||
*
|
||||
* myMockFn.withImplementation(() => 'temp', () => {
|
||||
* myMockFn() // 'temp'
|
||||
* })
|
||||
*
|
||||
* myMockFn() // 'original'
|
||||
*/
|
||||
withImplementation<T2>(fn: NormalizedProcedure<T>, cb: () => T2): T2 extends Promise<unknown> ? Promise<this> : this;
|
||||
/**
|
||||
* Use this if you need to return the `this` context from the method without invoking the actual implementation.
|
||||
* @see https://vitest.dev/api/mock#mockreturnthis
|
||||
*/
|
||||
mockReturnThis(): this;
|
||||
/**
|
||||
* Accepts a value that will be returned whenever the mock function is called. TypeScript will only accept values that match the return type of the original function.
|
||||
* @see https://vitest.dev/api/mock#mockreturnvalue
|
||||
* @example
|
||||
* const mock = vi.fn()
|
||||
* mock.mockReturnValue(42)
|
||||
* mock() // 42
|
||||
* mock.mockReturnValue(43)
|
||||
* mock() // 43
|
||||
*/
|
||||
mockReturnValue(value: ReturnType<T>): this;
|
||||
/**
|
||||
* Accepts a value that will be returned whenever the mock function is called. TypeScript will only accept values that match the return type of the original function.
|
||||
*
|
||||
* When the mocked function runs out of implementations, it will invoke the default implementation set with `vi.fn(() => defaultValue)` or `.mockImplementation(() => defaultValue)` if they were called.
|
||||
* @example
|
||||
* const myMockFn = vi
|
||||
* .fn()
|
||||
* .mockReturnValue('default')
|
||||
* .mockReturnValueOnce('first call')
|
||||
* .mockReturnValueOnce('second call')
|
||||
*
|
||||
* // 'first call', 'second call', 'default'
|
||||
* console.log(myMockFn(), myMockFn(), myMockFn())
|
||||
*/
|
||||
mockReturnValueOnce(value: ReturnType<T>): this;
|
||||
/**
|
||||
* Accepts a value that will be resolved when the async function is called. TypeScript will only accept values that match the return type of the original function.
|
||||
* @example
|
||||
* const asyncMock = vi.fn().mockResolvedValue(42)
|
||||
* asyncMock() // Promise<42>
|
||||
*/
|
||||
mockResolvedValue(value: Awaited<ReturnType<T>>): this;
|
||||
/**
|
||||
* Accepts a value that will be resolved during the next function call. TypeScript will only accept values that match the return type of the original function. If chained, each consecutive call will resolve the specified value.
|
||||
* @example
|
||||
* const myMockFn = vi
|
||||
* .fn()
|
||||
* .mockResolvedValue('default')
|
||||
* .mockResolvedValueOnce('first call')
|
||||
* .mockResolvedValueOnce('second call')
|
||||
*
|
||||
* // Promise<'first call'>, Promise<'second call'>, Promise<'default'>
|
||||
* console.log(myMockFn(), myMockFn(), myMockFn())
|
||||
*/
|
||||
mockResolvedValueOnce(value: Awaited<ReturnType<T>>): this;
|
||||
/**
|
||||
* Accepts an error that will be rejected when async function is called.
|
||||
* @example
|
||||
* const asyncMock = vi.fn().mockRejectedValue(new Error('Async error'))
|
||||
* await asyncMock() // throws Error<'Async error'>
|
||||
*/
|
||||
mockRejectedValue(error: unknown): this;
|
||||
/**
|
||||
* Accepts a value that will be rejected during the next function call. If chained, each consecutive call will reject the specified value.
|
||||
* @example
|
||||
* const asyncMock = vi
|
||||
* .fn()
|
||||
* .mockResolvedValueOnce('first call')
|
||||
* .mockRejectedValueOnce(new Error('Async error'))
|
||||
*
|
||||
* await asyncMock() // first call
|
||||
* await asyncMock() // throws Error<'Async error'>
|
||||
*/
|
||||
mockRejectedValueOnce(error: unknown): this;
|
||||
}
|
||||
/* eslint-enable ts/method-signature-style */
|
||||
interface Mock<T extends Procedure = Procedure> extends MockInstance<T> {
|
||||
new (...args: Parameters<T>): ReturnType<T>;
|
||||
(...args: Parameters<T>): ReturnType<T>;
|
||||
}
|
||||
type PartialMaybePromise<T> = T extends Promise<Awaited<T>> ? Promise<Partial<Awaited<T>>> : Partial<T>;
|
||||
interface PartialMock<T extends Procedure = Procedure> extends MockInstance<(...args: Parameters<T>) => PartialMaybePromise<ReturnType<T>>> {
|
||||
new (...args: Parameters<T>): ReturnType<T>;
|
||||
(...args: Parameters<T>): ReturnType<T>;
|
||||
}
|
||||
type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? Mock<(...args: ConstructorParameters<T>) => R> : T;
|
||||
type MockedFunction<T extends Procedure> = Mock<T> & { [K in keyof T] : T[K] };
|
||||
type PartiallyMockedFunction<T extends Procedure> = PartialMock<T> & { [K in keyof T] : T[K] };
|
||||
type MockedFunctionDeep<T extends Procedure> = Mock<T> & MockedObjectDeep<T>;
|
||||
type PartiallyMockedFunctionDeep<T extends Procedure> = PartialMock<T> & MockedObjectDeep<T>;
|
||||
type MockedObject<T> = MaybeMockedConstructor<T> & { [K in Methods<T>] : T[K] extends Procedure ? MockedFunction<T[K]> : T[K] } & { [K in Properties<T>] : T[K] };
|
||||
type MockedObjectDeep<T> = MaybeMockedConstructor<T> & { [K in Methods<T>] : T[K] extends Procedure ? MockedFunctionDeep<T[K]> : T[K] } & { [K in Properties<T>] : MaybeMockedDeep<T[K]> };
|
||||
type MaybeMockedDeep<T> = T extends Procedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
||||
type MaybePartiallyMockedDeep<T> = T extends Procedure ? PartiallyMockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
||||
type MaybeMocked<T> = T extends Procedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
||||
type MaybePartiallyMocked<T> = T extends Procedure ? PartiallyMockedFunction<T> : T extends object ? MockedObject<T> : T;
|
||||
interface Constructable {
|
||||
new (...args: any[]): any;
|
||||
}
|
||||
type MockedClass<T extends Constructable> = MockInstance<(...args: ConstructorParameters<T>) => InstanceType<T>> & {
|
||||
prototype: T extends {
|
||||
prototype: any
|
||||
} ? Mocked<T["prototype"]> : never
|
||||
} & T;
|
||||
type Mocked<T> = { [P in keyof T] : T[P] extends Procedure ? MockInstance<T[P]> : T[P] extends Constructable ? MockedClass<T[P]> : T[P] } & T;
|
||||
declare const mocks: Set<MockInstance<any>>;
|
||||
declare function isMockFunction(fn: any): fn is MockInstance;
|
||||
declare function spyOn<
|
||||
T,
|
||||
S extends Properties<Required<T>>
|
||||
>(obj: T, methodName: S, accessType: "get"): MockInstance<() => T[S]>;
|
||||
declare function spyOn<
|
||||
T,
|
||||
G extends Properties<Required<T>>
|
||||
>(obj: T, methodName: G, accessType: "set"): MockInstance<(arg: T[G]) => void>;
|
||||
declare function spyOn<
|
||||
T,
|
||||
M extends Classes<Required<T>> | Methods<Required<T>>
|
||||
>(obj: T, methodName: M): Required<T>[M] extends {
|
||||
new (...args: infer A): infer R
|
||||
} ? MockInstance<(this: R, ...args: A) => R> : T[M] extends Procedure ? MockInstance<T[M]> : never;
|
||||
declare function fn<T extends Procedure = Procedure>(implementation?: T): Mock<T>;
|
||||
|
||||
export { fn, isMockFunction, mocks, spyOn };
|
||||
export type { MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MaybePartiallyMocked, MaybePartiallyMockedDeep, Mock, MockContext, MockInstance, MockResult, MockSettledResult, Mocked, MockedClass, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, PartialMock, PartiallyMockedFunction, PartiallyMockedFunctionDeep };
|
||||
191
frontend/node_modules/@vitest/spy/dist/index.js
generated
vendored
Normal file
191
frontend/node_modules/@vitest/spy/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
import * as tinyspy from 'tinyspy';
|
||||
|
||||
const mocks = new Set();
|
||||
function isMockFunction(fn) {
|
||||
return typeof fn === "function" && "_isMockFunction" in fn && fn._isMockFunction;
|
||||
}
|
||||
function spyOn(obj, method, accessType) {
|
||||
const dictionary = {
|
||||
get: "getter",
|
||||
set: "setter"
|
||||
};
|
||||
const objMethod = accessType ? { [dictionary[accessType]]: method } : method;
|
||||
let state;
|
||||
const descriptor = getDescriptor(obj, method);
|
||||
const fn = descriptor && descriptor[accessType || "value"];
|
||||
// inherit implementations if it was already mocked
|
||||
if (isMockFunction(fn)) {
|
||||
state = fn.mock._state();
|
||||
}
|
||||
try {
|
||||
const stub = tinyspy.internalSpyOn(obj, objMethod);
|
||||
const spy = enhanceSpy(stub);
|
||||
if (state) {
|
||||
spy.mock._state(state);
|
||||
}
|
||||
return spy;
|
||||
} catch (error) {
|
||||
if (error instanceof TypeError && Symbol.toStringTag && obj[Symbol.toStringTag] === "Module" && (error.message.includes("Cannot redefine property") || error.message.includes("Cannot replace module namespace") || error.message.includes("can't redefine non-configurable property"))) {
|
||||
throw new TypeError(`Cannot spy on export "${String(objMethod)}". Module namespace is not configurable in ESM. See: https://vitest.dev/guide/browser/#limitations`, { cause: error });
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
let callOrder = 0;
|
||||
function enhanceSpy(spy) {
|
||||
const stub = spy;
|
||||
let implementation;
|
||||
let onceImplementations = [];
|
||||
let implementationChangedTemporarily = false;
|
||||
let instances = [];
|
||||
let contexts = [];
|
||||
let invocations = [];
|
||||
const state = tinyspy.getInternalState(spy);
|
||||
const mockContext = {
|
||||
get calls() {
|
||||
return state.calls;
|
||||
},
|
||||
get contexts() {
|
||||
return contexts;
|
||||
},
|
||||
get instances() {
|
||||
return instances;
|
||||
},
|
||||
get invocationCallOrder() {
|
||||
return invocations;
|
||||
},
|
||||
get results() {
|
||||
return state.results.map(([callType, value]) => {
|
||||
const type = callType === "error" ? "throw" : "return";
|
||||
return {
|
||||
type,
|
||||
value
|
||||
};
|
||||
});
|
||||
},
|
||||
get settledResults() {
|
||||
return state.resolves.map(([callType, value]) => {
|
||||
const type = callType === "error" ? "rejected" : "fulfilled";
|
||||
return {
|
||||
type,
|
||||
value
|
||||
};
|
||||
});
|
||||
},
|
||||
get lastCall() {
|
||||
return state.calls[state.calls.length - 1];
|
||||
},
|
||||
_state(state) {
|
||||
if (state) {
|
||||
implementation = state.implementation;
|
||||
onceImplementations = state.onceImplementations;
|
||||
implementationChangedTemporarily = state.implementationChangedTemporarily;
|
||||
}
|
||||
return {
|
||||
implementation,
|
||||
onceImplementations,
|
||||
implementationChangedTemporarily
|
||||
};
|
||||
}
|
||||
};
|
||||
function mockCall(...args) {
|
||||
instances.push(this);
|
||||
contexts.push(this);
|
||||
invocations.push(++callOrder);
|
||||
const impl = implementationChangedTemporarily ? implementation : onceImplementations.shift() || implementation || state.getOriginal() || (() => {});
|
||||
return impl.apply(this, args);
|
||||
}
|
||||
let name = stub.name;
|
||||
stub.getMockName = () => name || "vi.fn()";
|
||||
stub.mockName = (n) => {
|
||||
name = n;
|
||||
return stub;
|
||||
};
|
||||
stub.mockClear = () => {
|
||||
state.reset();
|
||||
instances = [];
|
||||
contexts = [];
|
||||
invocations = [];
|
||||
return stub;
|
||||
};
|
||||
stub.mockReset = () => {
|
||||
stub.mockClear();
|
||||
implementation = undefined;
|
||||
onceImplementations = [];
|
||||
return stub;
|
||||
};
|
||||
stub.mockRestore = () => {
|
||||
stub.mockReset();
|
||||
state.restore();
|
||||
return stub;
|
||||
};
|
||||
if (Symbol.dispose) {
|
||||
stub[Symbol.dispose] = () => stub.mockRestore();
|
||||
}
|
||||
stub.getMockImplementation = () => implementationChangedTemporarily ? implementation : onceImplementations.at(0) || implementation;
|
||||
stub.mockImplementation = (fn) => {
|
||||
implementation = fn;
|
||||
state.willCall(mockCall);
|
||||
return stub;
|
||||
};
|
||||
stub.mockImplementationOnce = (fn) => {
|
||||
onceImplementations.push(fn);
|
||||
return stub;
|
||||
};
|
||||
function withImplementation(fn, cb) {
|
||||
const originalImplementation = implementation;
|
||||
implementation = fn;
|
||||
state.willCall(mockCall);
|
||||
implementationChangedTemporarily = true;
|
||||
const reset = () => {
|
||||
implementation = originalImplementation;
|
||||
implementationChangedTemporarily = false;
|
||||
};
|
||||
const result = cb();
|
||||
if (typeof result === "object" && result && typeof result.then === "function") {
|
||||
return result.then(() => {
|
||||
reset();
|
||||
return stub;
|
||||
});
|
||||
}
|
||||
reset();
|
||||
return stub;
|
||||
}
|
||||
stub.withImplementation = withImplementation;
|
||||
stub.mockReturnThis = () => stub.mockImplementation(function() {
|
||||
return this;
|
||||
});
|
||||
stub.mockReturnValue = (val) => stub.mockImplementation(() => val);
|
||||
stub.mockReturnValueOnce = (val) => stub.mockImplementationOnce(() => val);
|
||||
stub.mockResolvedValue = (val) => stub.mockImplementation(() => Promise.resolve(val));
|
||||
stub.mockResolvedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.resolve(val));
|
||||
stub.mockRejectedValue = (val) => stub.mockImplementation(() => Promise.reject(val));
|
||||
stub.mockRejectedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.reject(val));
|
||||
Object.defineProperty(stub, "mock", { get: () => mockContext });
|
||||
state.willCall(mockCall);
|
||||
mocks.add(stub);
|
||||
return stub;
|
||||
}
|
||||
function fn(implementation) {
|
||||
const enhancedSpy = enhanceSpy(tinyspy.internalSpyOn({ spy: implementation || function() {} }, "spy"));
|
||||
if (implementation) {
|
||||
enhancedSpy.mockImplementation(implementation);
|
||||
}
|
||||
return enhancedSpy;
|
||||
}
|
||||
function getDescriptor(obj, method) {
|
||||
const objDescriptor = Object.getOwnPropertyDescriptor(obj, method);
|
||||
if (objDescriptor) {
|
||||
return objDescriptor;
|
||||
}
|
||||
let currentProto = Object.getPrototypeOf(obj);
|
||||
while (currentProto !== null) {
|
||||
const descriptor = Object.getOwnPropertyDescriptor(currentProto, method);
|
||||
if (descriptor) {
|
||||
return descriptor;
|
||||
}
|
||||
currentProto = Object.getPrototypeOf(currentProto);
|
||||
}
|
||||
}
|
||||
|
||||
export { fn, isMockFunction, mocks, spyOn };
|
||||
38
frontend/node_modules/@vitest/spy/package.json
generated
vendored
Normal file
38
frontend/node_modules/@vitest/spy/package.json
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@vitest/spy",
|
||||
"type": "module",
|
||||
"version": "3.2.4",
|
||||
"description": "Lightweight Jest compatible spy implementation",
|
||||
"license": "MIT",
|
||||
"funding": "https://opencollective.com/vitest",
|
||||
"homepage": "https://github.com/vitest-dev/vitest/tree/main/packages/spy#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vitest-dev/vitest.git",
|
||||
"directory": "packages/spy"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vitest-dev/vitest/issues"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./*": "./*"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"tinyspy": "^4.0.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rimraf dist && rollup -c",
|
||||
"dev": "rollup -c --watch"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user