1 | // Type definitions for sinon-chai 2.7.0
|
2 | // Project: https://github.com/domenic/sinon-chai
|
3 | // Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid>, Jed Mao <https://github.com/jedmao>
|
4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
5 | // TypeScript Version: 2.8
|
6 |
|
7 | /// <reference types="chai" />
|
8 | /// <reference types="sinon" />
|
9 |
|
10 | import * as Sinon from 'sinon';
|
11 |
|
12 | declare global {
|
13 |
|
14 | export namespace Chai {
|
15 |
|
16 | interface LanguageChains {
|
17 | always: Assertion;
|
18 | }
|
19 |
|
20 | interface Assertion {
|
21 | /**
|
22 | * true if the spy was called at least once.
|
23 | */
|
24 | called: Assertion;
|
25 | /**
|
26 | * @param count The number of recorded calls.
|
27 | */
|
28 | callCount(count: number): Assertion;
|
29 | /**
|
30 | * true if the spy was called exactly once.
|
31 | */
|
32 | calledOnce: Assertion;
|
33 | /**
|
34 | * true if the spy was called exactly twice.
|
35 | */
|
36 | calledTwice: Assertion;
|
37 | /**
|
38 | * true if the spy was called exactly thrice.
|
39 | */
|
40 | calledThrice: Assertion;
|
41 | /**
|
42 | * Returns true if the spy was called before anotherSpy.
|
43 | */
|
44 | calledBefore(anotherSpy: Sinon.SinonSpy): Assertion;
|
45 | /**
|
46 | * Returns true if the spy was called after anotherSpy.
|
47 | */
|
48 | calledAfter(anotherSpy: Sinon.SinonSpy): Assertion;
|
49 | /**
|
50 | * Returns true if spy/stub was called with the new operator. Beware that
|
51 | * this is inferred based on the value of the this object and the spy
|
52 | * function's prototype, so it may give false positives if you actively
|
53 | * return the right kind of object.
|
54 | */
|
55 | calledWithNew: Assertion;
|
56 | /**
|
57 | * Returns true if context was this for this call.
|
58 | */
|
59 | calledOn(context: any): Assertion;
|
60 | /**
|
61 | * Returns true if call received provided arguments (and possibly others).
|
62 | */
|
63 | calledWith(...args: any[]): Assertion;
|
64 | /**
|
65 | * Returns true if call received provided arguments and no others.
|
66 | */
|
67 | calledWithExactly(...args: any[]): Assertion;
|
68 | /**
|
69 | * Returns true if call received matching arguments (and possibly others).
|
70 | * This behaves the same as spyCall.calledWith(sinon.match(arg1), sinon.match(arg2), ...).
|
71 | */
|
72 | calledWithMatch(...args: any[]): Assertion;
|
73 | /**
|
74 | * Returns true if spy returned the provided value at least once. Uses
|
75 | * deep comparison for objects and arrays. Use spy.returned(sinon.match.same(obj))
|
76 | * for strict comparison (see matchers).
|
77 | */
|
78 | returned(obj: any): Assertion;
|
79 | /**
|
80 | * Returns true if spy threw the provided exception object at least once.
|
81 | */
|
82 | thrown(obj?: Error | typeof Error | string): Assertion;
|
83 | }
|
84 | }
|
85 | }
|
86 |
|
87 | declare function sinonChai(chai: any, utils: any): void;
|
88 | declare namespace sinonChai { }
|
89 | export = sinonChai;
|