@types/jest-when
Advanced tools
Comparing version 2.7.4 to 3.5.0
@@ -1,2 +0,2 @@ | ||
// Type definitions for jest-when 2.7 | ||
// Type definitions for jest-when 3.5 | ||
// Project: https://github.com/timkindberg/jest-when#readme | ||
@@ -12,20 +12,40 @@ // Definitions by: Alden Taylor <https://github.com/aldentaylor> | ||
export interface WhenMock<T = any, Y extends any[] = any> | ||
extends jest.MockInstance<T, Y> { | ||
calledWith(...matchers: Y): this; | ||
expectCalledWith(...matchers: Y): this; | ||
mockReturnValue(value: T): this; | ||
mockReturnValueOnce(value: T): this; | ||
mockResolvedValue(value: jest.ResolvedValue<T>): this; | ||
mockResolvedValueOnce(value: jest.ResolvedValue<T>): this; | ||
mockRejectedValue(value: jest.RejectedValue<T>): this; | ||
mockRejectedValueOnce(value: jest.RejectedValue<T>): this; | ||
mockImplementation(fn: (...args: Y) => T): this; | ||
mockImplementationOnce(fn?: (...args: Y) => T): this; | ||
export type ArgumentOrMatcher<ArgTypes extends any[]> = { | ||
[Index in keyof ArgTypes]: ArgTypes[Index] | WhenMock<boolean, [ArgTypes[Index]]>; | ||
}; | ||
export interface WhenMock<T = any, Y extends any[] = any> extends jest.MockInstance<T, Y> { | ||
calledWith(allArgsMatcher: AllArgsMatcher<Y>): this; | ||
calledWith(...matchers: ArgumentOrMatcher<Y>): this; | ||
expectCalledWith(allArgsMatcher: AllArgsMatcher<Y>): this; | ||
expectCalledWith(...matchers: ArgumentOrMatcher<Y>): this; | ||
mockReturnValue(value: T): this; | ||
mockReturnValueOnce(value: T): this; | ||
mockResolvedValue(value: jest.ResolvedValue<T>): this; | ||
mockResolvedValueOnce(value: jest.ResolvedValue<T>): this; | ||
mockRejectedValue(value: jest.RejectedValue<T>): this; | ||
mockRejectedValueOnce(value: jest.RejectedValue<T>): this; | ||
mockImplementation(fn: (...args: Y) => T): this; | ||
mockImplementationOnce(fn?: (...args: Y) => T): this; | ||
defaultReturnValue(value: T): this; | ||
defaultResolvedValue(value: jest.ResolvedValue<T>): this; | ||
defaultRejectedValue(value: jest.RejectedValue<T>): this; | ||
defaultImplementation(fn: (...args: Y) => T): this; | ||
} | ||
export type When = <T, Y extends any[]>(fn: ((...args: Y) => T) | jest.MockInstance<T, Y>) => WhenMock<T, Y>; | ||
export interface AllArgsMatcher<Y> { | ||
(args: Y, equals: jest.MatcherUtils['equals']): boolean; | ||
// Internal, but needed to distinguish from normal callables | ||
_isAllArgsFunctionMatcher: true; | ||
_isFunctionMatcher: true; | ||
} | ||
export interface When { | ||
<T, Y extends any[]>(fn: ((...args: Y) => T) | jest.MockInstance<T, Y>): WhenMock<T, Y>; | ||
allArgs<Y extends any[]>(matcher: (args: Y, equals: jest.MatcherUtils['equals']) => boolean): AllArgsMatcher<Y>; | ||
} | ||
export const when: When; | ||
export function resetAllWhenMocks(): void; | ||
export function verifyAllWhenMocksCalled(): void; |
{ | ||
"name": "@types/jest-when", | ||
"version": "2.7.4", | ||
"version": "3.5.0", | ||
"description": "TypeScript definitions for jest-when", | ||
@@ -40,4 +40,4 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest-when", | ||
}, | ||
"typesPublisherContentHash": "d2e9e0890a15abc32077d682a68562eca7c0311553a8a69e02c21267b08b617f", | ||
"typesPublisherContentHash": "eb375cead128870dd56f922ff2d614e736547bcdcb7a54784468492a746746e5", | ||
"typeScriptVersion": "3.8" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
````ts | ||
// Type definitions for jest-when 2.7 | ||
// Type definitions for jest-when 3.5 | ||
// Project: https://github.com/timkindberg/jest-when#readme | ||
@@ -23,18 +23,38 @@ // Definitions by: Alden Taylor <https://github.com/aldentaylor> | ||
export interface WhenMock<T = any, Y extends any[] = any> | ||
extends jest.MockInstance<T, Y> { | ||
calledWith(...matchers: Y): this; | ||
expectCalledWith(...matchers: Y): this; | ||
mockReturnValue(value: T): this; | ||
mockReturnValueOnce(value: T): this; | ||
mockResolvedValue(value: jest.ResolvedValue<T>): this; | ||
mockResolvedValueOnce(value: jest.ResolvedValue<T>): this; | ||
mockRejectedValue(value: jest.RejectedValue<T>): this; | ||
mockRejectedValueOnce(value: jest.RejectedValue<T>): this; | ||
mockImplementation(fn: (...args: Y) => T): this; | ||
mockImplementationOnce(fn?: (...args: Y) => T): this; | ||
export type ArgumentOrMatcher<ArgTypes extends any[]> = { | ||
[Index in keyof ArgTypes]: ArgTypes[Index] | WhenMock<boolean, [ArgTypes[Index]]>; | ||
}; | ||
export interface WhenMock<T = any, Y extends any[] = any> extends jest.MockInstance<T, Y> { | ||
calledWith(allArgsMatcher: AllArgsMatcher<Y>): this; | ||
calledWith(...matchers: ArgumentOrMatcher<Y>): this; | ||
expectCalledWith(allArgsMatcher: AllArgsMatcher<Y>): this; | ||
expectCalledWith(...matchers: ArgumentOrMatcher<Y>): this; | ||
mockReturnValue(value: T): this; | ||
mockReturnValueOnce(value: T): this; | ||
mockResolvedValue(value: jest.ResolvedValue<T>): this; | ||
mockResolvedValueOnce(value: jest.ResolvedValue<T>): this; | ||
mockRejectedValue(value: jest.RejectedValue<T>): this; | ||
mockRejectedValueOnce(value: jest.RejectedValue<T>): this; | ||
mockImplementation(fn: (...args: Y) => T): this; | ||
mockImplementationOnce(fn?: (...args: Y) => T): this; | ||
defaultReturnValue(value: T): this; | ||
defaultResolvedValue(value: jest.ResolvedValue<T>): this; | ||
defaultRejectedValue(value: jest.RejectedValue<T>): this; | ||
defaultImplementation(fn: (...args: Y) => T): this; | ||
} | ||
export type When = <T, Y extends any[]>(fn: ((...args: Y) => T) | jest.MockInstance<T, Y>) => WhenMock<T, Y>; | ||
export interface AllArgsMatcher<Y> { | ||
(args: Y, equals: jest.MatcherUtils['equals']): boolean; | ||
// Internal, but needed to distinguish from normal callables | ||
_isAllArgsFunctionMatcher: true; | ||
_isFunctionMatcher: true; | ||
} | ||
export interface When { | ||
<T, Y extends any[]>(fn: ((...args: Y) => T) | jest.MockInstance<T, Y>): WhenMock<T, Y>; | ||
allArgs<Y extends any[]>(matcher: (args: Y, equals: jest.MatcherUtils['equals']) => boolean): AllArgsMatcher<Y>; | ||
} | ||
export const when: When; | ||
@@ -47,3 +67,3 @@ export function resetAllWhenMocks(): void; | ||
### Additional Details | ||
* Last updated: Thu, 23 Dec 2021 23:34:54 GMT | ||
* Last updated: Tue, 01 Feb 2022 21:01:25 GMT | ||
* Dependencies: [@types/jest](https://npmjs.com/package/@types/jest) | ||
@@ -50,0 +70,0 @@ * Global values: none |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7677
43
71