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