From 5d309ff52cd399a6b71968a6b9a70c8ac0b98981 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 5 Mar 2022 19:02:27 +0200 Subject: Added node_modules for the updating to work properly. --- node_modules/jest-mock/build/index.d.ts | 185 ++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 node_modules/jest-mock/build/index.d.ts (limited to 'node_modules/jest-mock/build/index.d.ts') diff --git a/node_modules/jest-mock/build/index.d.ts b/node_modules/jest-mock/build/index.d.ts new file mode 100644 index 0000000..f345294 --- /dev/null +++ b/node_modules/jest-mock/build/index.d.ts @@ -0,0 +1,185 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +export declare type MockFunctionMetadataType = 'object' | 'array' | 'regexp' | 'function' | 'constant' | 'collection' | 'null' | 'undefined'; +export declare type MockFunctionMetadata, Type = MockFunctionMetadataType> = { + ref?: number; + members?: Record>; + mockImpl?: (...args: Y) => T; + name?: string; + refID?: number; + type?: Type; + value?: T; + length?: number; +}; +export declare type MockableFunction = (...args: Array) => any; +export declare type MethodKeysOf = { + [K in keyof T]: T[K] extends MockableFunction ? K : never; +}[keyof T]; +export declare type PropertyKeysOf = { + [K in keyof T]: T[K] extends MockableFunction ? never : K; +}[keyof T]; +export declare type ArgumentsOf = T extends (...args: infer A) => any ? A : never; +export declare type ConstructorArgumentsOf = T extends new (...args: infer A) => any ? A : never; +export declare type MaybeMockedConstructor = T extends new (...args: Array) => infer R ? MockInstance> : T; +export declare type MockedFunction = MockWithArgs & { + [K in keyof T]: T[K]; +}; +export declare type MockedFunctionDeep = MockWithArgs & MockedObjectDeep; +export declare type MockedObject = MaybeMockedConstructor & { + [K in MethodKeysOf]: T[K] extends MockableFunction ? MockedFunction : T[K]; +} & { + [K in PropertyKeysOf]: T[K]; +}; +export declare type MockedObjectDeep = MaybeMockedConstructor & { + [K in MethodKeysOf]: T[K] extends MockableFunction ? MockedFunctionDeep : T[K]; +} & { + [K in PropertyKeysOf]: MaybeMockedDeep; +}; +export declare type MaybeMockedDeep = T extends MockableFunction ? MockedFunctionDeep : T extends object ? MockedObjectDeep : T; +export declare type MaybeMocked = T extends MockableFunction ? MockedFunction : T extends object ? MockedObject : T; +export declare type ArgsType = T extends (...args: infer A) => any ? A : never; +export declare type Mocked = { + [P in keyof T]: T[P] extends (...args: Array) => any ? MockInstance, ArgsType> : T[P] extends Constructable ? MockedClass : T[P]; +} & T; +export declare type MockedClass = MockInstance, T extends new (...args: infer P) => any ? P : never> & { + prototype: T extends { + prototype: any; + } ? Mocked : never; +} & T; +export interface Constructable { + new (...args: Array): any; +} +export interface MockWithArgs extends MockInstance, ArgumentsOf> { + new (...args: ConstructorArgumentsOf): T; + (...args: ArgumentsOf): ReturnType; +} +export interface Mock = Array> extends Function, MockInstance { + new (...args: Y): T; + (...args: Y): T; +} +export interface SpyInstance> extends MockInstance { +} +export interface MockInstance> { + _isMockFunction: true; + _protoImpl: Function; + getMockName(): string; + getMockImplementation(): Function | undefined; + mock: MockFunctionState; + mockClear(): this; + mockReset(): this; + mockRestore(): void; + mockImplementation(fn: (...args: Y) => T): this; + mockImplementation(fn: () => Promise): this; + mockImplementationOnce(fn: (...args: Y) => T): this; + mockImplementationOnce(fn: () => Promise): this; + mockName(name: string): this; + mockReturnThis(): this; + mockReturnValue(value: T): this; + mockReturnValueOnce(value: T): this; + mockResolvedValue(value: Unpromisify): this; + mockResolvedValueOnce(value: Unpromisify): this; + mockRejectedValue(value: unknown): this; + mockRejectedValueOnce(value: unknown): this; +} +declare type Unpromisify = T extends Promise ? R : never; +/** + * Possible types of a MockFunctionResult. + * 'return': The call completed by returning normally. + * 'throw': The call completed by throwing a value. + * 'incomplete': The call has not completed yet. This is possible if you read + * the mock function result from within the mock function itself + * (or a function called by the mock function). + */ +declare type MockFunctionResultType = 'return' | 'throw' | 'incomplete'; +/** + * Represents the result of a single call to a mock function. + */ +declare type MockFunctionResult = { + /** + * Indicates how the call completed. + */ + type: MockFunctionResultType; + /** + * The value that was either thrown or returned by the function. + * Undefined when type === 'incomplete'. + */ + value: unknown; +}; +declare type MockFunctionState> = { + calls: Array; + instances: Array; + invocationCallOrder: Array; + /** + * Getter for retrieving the last call arguments + */ + lastCall?: Y; + /** + * List of results of calls to the mock function. + */ + results: Array; +}; +declare type NonFunctionPropertyNames = { + [K in keyof T]: T[K] extends (...args: Array) => any ? never : K; +}[keyof T] & string; +declare type FunctionPropertyNames = { + [K in keyof T]: T[K] extends (...args: Array) => any ? K : never; +}[keyof T] & string; +export declare class ModuleMocker { + private _environmentGlobal; + private _mockState; + private _mockConfigRegistry; + private _spyState; + private _invocationCallCounter; + /** + * @see README.md + * @param global Global object of the test environment, used to create + * mocks + */ + constructor(global: typeof globalThis); + private _getSlots; + private _ensureMockConfig; + private _ensureMockState; + private _defaultMockConfig; + private _defaultMockState; + private _makeComponent; + private _createMockFunction; + private _generateMock; + /** + * @see README.md + * @param _metadata Metadata for the mock in the schema returned by the + * getMetadata method of this module. + */ + generateFromMetadata>(_metadata: MockFunctionMetadata): Mock; + /** + * @see README.md + * @param component The component for which to retrieve metadata. + */ + getMetadata>(component: T, _refs?: Map): MockFunctionMetadata | null; + isMockFunction(fn: unknown): fn is Mock; + fn>(implementation?: (...args: Y) => T): Mock; + spyOn>(object: T, methodName: M, accessType: 'get'): SpyInstance; + spyOn>(object: T, methodName: M, accessType: 'set'): SpyInstance; + spyOn>(object: T, methodName: M): T[M] extends (...args: Array) => any ? SpyInstance, Parameters> : never; + private _spyOnProperty; + clearAllMocks(): void; + resetAllMocks(): void; + restoreAllMocks(): void; + private _typeOf; + mocked(item: T, deep?: false): MaybeMocked; + mocked(item: T, deep: true): MaybeMockedDeep; +} +export declare const fn: (implementation?: ((...args: Y) => T) | undefined) => Mock; +export declare const spyOn: { + >(object: T, methodName: M, accessType: 'get'): SpyInstance; + >(object: T_2, methodName: M_2, accessType: 'set'): SpyInstance; + >(object: T_4, methodName: M_4): T_4[M_4] extends (...args: Array) => any ? SpyInstance, Parameters> : never; +}; +export declare const mocked: { + (item: T, deep?: false | undefined): MaybeMocked; + (item: T_2, deep: true): MaybeMockedDeep; +}; +export {}; -- cgit v1.2.3