@types/jest-when
Advanced tools
Comparing version 3.5.1 to 3.5.2
@@ -7,2 +7,3 @@ // Type definitions for jest-when 3.5 | ||
// Nicholas Hehr <https://github.com/hipsterbrown> | ||
// Bogi Napoleon Wennerström <https://github.com/boginw> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
@@ -17,21 +18,33 @@ // Minimum TypeScript Version: 4.3 | ||
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 interface WhenMock<T = any, Y extends any[] = any> { | ||
calledWith(allArgsMatcher: AllArgsMatcher<Y>): WhenMockWithMatchers<T, Y>; | ||
calledWith(...matchers: ArgumentOrMatcher<Y>): WhenMockWithMatchers<T, Y>; | ||
expectCalledWith(allArgsMatcher: AllArgsMatcher<Y>): WhenMockWithMatchers<T, Y>; | ||
expectCalledWith(...matchers: ArgumentOrMatcher<Y>): WhenMockWithMatchers<T, Y>; | ||
mockReturnValue(value: T): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
mockResolvedValue(value: jest.ResolvedValue<T>): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
mockRejectedValue(value: jest.RejectedValue<T>): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
mockImplementation(fn: (...args: Y) => T): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
defaultReturnValue(value: T): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
defaultResolvedValue(value: jest.ResolvedValue<T>): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
defaultRejectedValue(value: jest.RejectedValue<T>): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
defaultImplementation(fn: (...args: Y) => T): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
resetWhenMocks(): void; | ||
} | ||
export interface WhenMockWithMatchers<T = any, Y extends any[] = any> { | ||
mockReturnValue(value: T): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
mockReturnValueOnce(value: T): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
mockResolvedValue(value: jest.ResolvedValue<T>): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
mockResolvedValueOnce(value: jest.ResolvedValue<T>): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
mockRejectedValue(value: jest.RejectedValue<T>): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
mockRejectedValueOnce(value: jest.RejectedValue<T>): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
mockImplementation(fn: (...args: Y) => T): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
mockImplementationOnce(fn?: (...args: Y) => T): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
defaultImplementation(fn: (...args: Y) => T): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
defaultReturnValue(value: T): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
defaultResolvedValue(value: jest.ResolvedValue<T>): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
defaultRejectedValue(value: jest.RejectedValue<T>): WhenMockWithMatchers<T, Y> & WhenMock<T, Y>; | ||
} | ||
export interface AllArgsMatcher<Y> { | ||
@@ -38,0 +51,0 @@ (args: Y, equals: jest.MatcherUtils['equals']): boolean; |
{ | ||
"name": "@types/jest-when", | ||
"version": "3.5.1", | ||
"version": "3.5.2", | ||
"description": "TypeScript definitions for jest-when", | ||
@@ -27,2 +27,7 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest-when", | ||
"githubUsername": "hipsterbrown" | ||
}, | ||
{ | ||
"name": "Bogi Napoleon Wennerström", | ||
"url": "https://github.com/boginw", | ||
"githubUsername": "boginw" | ||
} | ||
@@ -41,4 +46,4 @@ ], | ||
}, | ||
"typesPublisherContentHash": "a785560834c6f715ac070d532254458ee76616d3a5fcfc9810fb15b011bd94e0", | ||
"typesPublisherContentHash": "a2181edc70b12801bebb91c21532ac19bb4ad11ea5619992bc81614c93fbd488", | ||
"typeScriptVersion": "4.3" | ||
} |
@@ -9,59 +9,5 @@ # Installation | ||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest-when. | ||
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest-when/index.d.ts) | ||
````ts | ||
// Type definitions for jest-when 3.5 | ||
// Project: https://github.com/timkindberg/jest-when#readme | ||
// Definitions by: Alden Taylor <https://github.com/aldentaylor> | ||
// Trung Dang <https://github.com/immanuel192> | ||
// Gregor Stamać <https://github.com/gstamac> | ||
// Nicholas Hehr <https://github.com/hipsterbrown> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// Minimum TypeScript Version: 4.3 | ||
/// <reference types="jest" /> | ||
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 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; | ||
```` | ||
### Additional Details | ||
* Last updated: Fri, 17 Jun 2022 12:01:41 GMT | ||
* Last updated: Thu, 30 Jun 2022 18:32:27 GMT | ||
* Dependencies: [@types/jest](https://npmjs.com/package/@types/jest) | ||
@@ -71,2 +17,2 @@ * Global values: none | ||
# Credits | ||
These definitions were written by [Alden Taylor](https://github.com/aldentaylor), [Trung Dang](https://github.com/immanuel192), [Gregor Stamać](https://github.com/gstamac), and [Nicholas Hehr](https://github.com/hipsterbrown). | ||
These definitions were written by [Alden Taylor](https://github.com/aldentaylor), [Trung Dang](https://github.com/immanuel192), [Gregor Stamać](https://github.com/gstamac), [Nicholas Hehr](https://github.com/hipsterbrown), and [Bogi Napoleon Wennerström](https://github.com/boginw). |
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
55
7008
17