UNPKG

4.16 kBTypeScriptView Raw
1/// <reference types="jasmine" />
2
3declare function it(expectation: string, assertion?: (done: DoneFn) => Promise<void>, timeout?: number): void;
4declare function fit(expectation: string, assertion?: (done: DoneFn) => Promise<void>, timeout?: number): void;
5declare function xit(expectation: string, assertion?: (done: DoneFn) => Promise<void>, timeout?: number): void;
6declare function beforeEach(action: (done: DoneFn) => Promise<void>, timeout?: number): void;
7declare function afterEach(action: (done: DoneFn) => Promise<void>, timeout?: number): void;
8declare function beforeAll(action: (done: DoneFn) => Promise<void>, timeout?: number): void;
9declare function afterAll(action: (done: DoneFn) => Promise<void>, timeout?: number): void;
10
11declare namespace jasmine {
12 interface Matchers<T> {
13 toBe(expected: any, expectationFailOutput?: any): Promise<void>;
14 toEqual(expected: any, expectationFailOutput?: any): Promise<void>;
15 toMatch(expected: string | RegExp | Promise<string | RegExp>, expectationFailOutput?: any): Promise<void>;
16 toBeDefined(expectationFailOutput?: any): Promise<void>;
17 toBeUndefined(expectationFailOutput?: any): Promise<void>;
18 toBeNull(expectationFailOutput?: any): Promise<void>;
19 toBeNaN(): Promise<void>;
20 toBeTruthy(expectationFailOutput?: any): Promise<void>;
21 toBeFalsy(expectationFailOutput?: any): Promise<void>;
22 toHaveBeenCalled(): Promise<void>;
23 toHaveBeenCalledWith(...params: any[]): Promise<void>;
24 toHaveBeenCalledTimes(expected: number | Promise<number>): Promise<void>;
25 toContain(expected: any, expectationFailOutput?: any): Promise<void>;
26 toBeLessThan(expected: number | Promise<number>, expectationFailOutput?: any): Promise<void>;
27 toBeLessThanOrEqual(expected: number | Promise<number>, expectationFailOutput?: any): Promise<void>;
28 toBeGreaterThan(expected: number | Promise<number>, expectationFailOutput?: any): Promise<void>;
29 toBeGreaterThanOrEqual(expected: number | Promise<number>, expectationFailOutput?: any): Promise<void>;
30 toBeCloseTo(expected: number | Promise<number>, precision?: any, expectationFailOutput?: any): Promise<void>;
31 toThrow(expected?: any): Promise<void>;
32 toThrowError(message?: string | RegExp | Promise<string | RegExp>): Promise<void>;
33 toThrowError(
34 expected?: new(...args: any[]) => Error | Promise<new(...args: any[]) => Error>,
35 message?: string | RegExp | Promise<string | RegExp>,
36 ): Promise<void>;
37 }
38
39 interface ArrayLikeMatchers<T> extends Matchers<ArrayLike<T>> {
40 toBe(expected: Expected<ArrayLike<T>>, expectationFailOutput?: any): Promise<void>;
41 toEqual(expected: Expected<ArrayLike<T>>, expectationFailOutput?: any): Promise<void>;
42 toContain(expected: T, expectationFailOutput?: any): Promise<void>;
43 not: ArrayLikeMatchers<T>;
44 }
45
46 // Add definition to be compatible with latest jasmine v3 types.
47 // Even though library is not compatible with jasmine v3, there is no suitable way to configure that now here.
48 // See for more detail: https://github.com/microsoft/dtslint/issues/253
49 interface FunctionMatchers<Fn extends (...args: any[]) => any> extends Matchers<any> {
50 toHaveBeenCalledWith(...params: any[]): boolean;
51 toHaveBeenCalledWith(...params: any[]): Promise<void>;
52 }
53
54 function addMatchers(matchers: AsyncCustomMatcherFactories): void;
55
56 interface Spec {
57 addMatchers(matchers: AsyncCustomMatcherFactories): void;
58 }
59
60 interface AsyncCustomMatcherFactories {
61 [index: string]: AsyncCustomMatcherFactory;
62 }
63
64 interface AsyncCustomMatcherFactory {
65 (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]): AsyncCustomMatcher;
66 }
67
68 interface AsyncCustomMatcher {
69 compare<T>(actual: T, expected: T): AsyncCustomMatcherResult;
70 compare(actual: any, expected: any): AsyncCustomMatcherResult;
71 }
72
73 interface AsyncCustomMatcherResult {
74 pass: boolean | Promise<boolean>;
75 message?: string | undefined;
76 }
77}