Files
DefinitelyTyped/types/saywhen/index.d.ts
Sean Sobey be9d76b7ce Added typings for jasmine plugin - saywhen. (#18206)
* Added typings for saywhen.

* Updated to pass linting.

* Removed redundant jasmine reference.

* Removed es2016 target.

* Updated defintions and tests.

* Fixed tests.

* Fixed linting
2017-07-26 07:04:54 -07:00

39 lines
883 B
TypeScript

// Type definitions for saywhen 1.1
// Project: https://github.com/pushtechnology/saywhen
// Definitions by: Sean Sobey <https://github.com/SeanSobey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="jasmine" />
type Func = (...args: any[]) => any;
declare function when<T extends Func>(spy: T & jasmine.Spy): CallHandler<T>;
declare namespace when {
function captor<T>(val?: T): MatcherProxy<T>;
function noConflict(): void;
function is<T>(val: T): boolean;
}
interface CallHandler<T extends Func> {
readonly isCalled: Proxy<T>;
isCalledWith(...args: any[]): Proxy<T>;
}
interface Proxy<T extends Func> {
then(fn: T): Proxy<T>;
thenReturn(val: any): Proxy<T>;
thenThrow(err: Error): Proxy<T>;
}
interface MatcherProxy<T> {
(arg: T): boolean;
readonly latest: T;
values(): T[];
}
export = when;