UNPKG

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