UNPKG

9.42 kBTypeScriptView Raw
1// Type definitions for chai 1.7.2
2// Project: http://chaijs.com/
3// Definitions by: Jed Hunsaker <https://github.com/jedhunsaker/>, Bart van der Schoor <https://github.com/Bartvds>
4// Definitions: https://github.com/borisyankov/DefinitelyTyped
5
6declare module chai {
7 export class AssertionError {
8 constructor(message: string, _props?: any, ssf?: Function);
9 name: string;
10 message: string;
11 showDiff: boolean;
12 stack: string;
13 }
14
15 function expect(target: any, message?: string): Expect;
16
17 export var assert: Assert;
18 export var config: Config;
19
20 export interface Config {
21 includeStack: boolean;
22 }
23
24 // Provides a way to extend the internals of Chai
25 function use(fn: (chai: any, utils: any) => void): any;
26
27 interface ExpectStatic {
28 (target: any): Expect;
29 }
30
31 interface Assertions {
32 attr(name: string, value?: string): any;
33 css(name: string, value?: string): any;
34 data(name: string, value?: string): any;
35 class(className: string): any;
36 id(id: string): any;
37 html(html: string): any;
38 text(text: string): any;
39 value(value: string): any;
40 visible: any;
41 hidden: any;
42 selected: any;
43 checked: any;
44 disabled: any;
45 empty: any;
46 exist: any;
47 }
48
49 interface Expect extends LanguageChains, NumericComparison, TypeComparison, Assertions {
50 not: Expect;
51 deep: Deep;
52 a: TypeComparison;
53 an: TypeComparison;
54 include: Include;
55 contain: Include;
56 ok: Expect;
57 true: Expect;
58 false: Expect;
59 null: Expect;
60 undefined: Expect;
61 exist: Expect;
62 empty: Expect;
63 arguments: Expect;
64 Arguments: Expect;
65 equal: Equal;
66 equals: Equal;
67 eq: Equal;
68 eql: Equal;
69 eqls: Equal;
70 property: Property;
71 ownProperty: OwnProperty;
72 haveOwnProperty: OwnProperty;
73 length: Length;
74 lengthOf: Length;
75 match(RegularExpression: RegExp, message?: string): Expect;
76 string(string: string, message?: string): Expect;
77 keys: Keys;
78 key(string: string): Expect;
79 throw: Throw;
80 throws: Throw;
81 Throw: Throw;
82 respondTo(method: string, message?: string): Expect;
83 itself: Expect;
84 satisfy(matcher: Function, message?: string): Expect;
85 closeTo(expected: number, delta: number, message?: string): Expect;
86 members: Members;
87 }
88
89 interface LanguageChains {
90 to: Expect;
91 be: Expect;
92 been: Expect;
93 is: Expect;
94 that: Expect;
95 and: Expect;
96 have: Expect;
97 has: Expect;
98 with: Expect;
99 at: Expect;
100 of: Expect;
101 same: Expect;
102 }
103
104 interface NumericComparison {
105 above: NumberComparer;
106 gt: NumberComparer;
107 greaterThan: NumberComparer;
108 least: NumberComparer;
109 gte: NumberComparer;
110 below: NumberComparer;
111 lt: NumberComparer;
112 lessThan: NumberComparer;
113 most: NumberComparer;
114 lte: NumberComparer;
115 within(start: number, finish: number, message?: string): Expect;
116 }
117
118 interface NumberComparer {
119 (value: number, message?: string): Expect;
120 }
121
122 interface TypeComparison {
123 (type: string, message?: string): Expect;
124 instanceof: InstanceOf;
125 instanceOf: InstanceOf;
126 }
127
128 interface InstanceOf {
129 (constructor: Object, message?: string): Expect;
130 }
131
132 interface Deep {
133 equal: Equal;
134 property: Property;
135 }
136
137 interface Equal {
138 (value: any, message?: string): Expect;
139 }
140
141 interface Property {
142 (name: string, value?: any, message?: string): Expect;
143 }
144
145 interface OwnProperty {
146 (name: string, message?: string): Expect;
147 }
148
149 interface Length extends LanguageChains, NumericComparison {
150 (length: number, message?: string): Expect;
151 }
152
153 interface Include {
154 (value: Object, message?: string): Expect;
155 (value: string, message?: string): Expect;
156 (value: number, message?: string): Expect;
157 keys: Keys;
158 members: Members;
159 }
160
161 interface Keys {
162 (...keys: string[]): Expect;
163 (keys: any[]): Expect;
164 }
165
166 interface Members {
167 (set: any[], message?: string): Expect;
168 }
169
170 interface Throw {
171 (): Expect;
172 (expected: string, message?: string): Expect;
173 (expected: RegExp, message?: string): Expect;
174 (constructor: Error, expected?: string, message?: string): Expect;
175 (constructor: Error, expected?: RegExp, message?: string): Expect;
176 (constructor: Function, expected?: string, message?: string): Expect;
177 (constructor: Function, expected?: RegExp, message?: string): Expect;
178 }
179
180 export interface Assert {
181 (express: any, msg?: string): void;
182
183 fail(actual?: any, expected?: any, msg?: string, operator?: string): void;
184
185 ok(val: any, msg?: string): void;
186 notOk(val: any, msg?: string): void;
187
188 equal(act: any, exp: any, msg?: string): void;
189 notEqual(act: any, exp: any, msg?: string): void;
190
191 strictEqual(act: any, exp: any, msg?: string): void;
192 notStrictEqual(act: any, exp: any, msg?: string): void;
193
194 deepEqual(act: any, exp: any, msg?: string): void;
195 notDeepEqual(act: any, exp: any, msg?: string): void;
196
197 isTrue(val: any, msg?: string): void;
198 isFalse(val: any, msg?: string): void;
199
200 isNull(val: any, msg?: string): void;
201 isNotNull(val: any, msg?: string): void;
202
203 isUndefined(val: any, msg?: string): void;
204 isDefined(val: any, msg?: string): void;
205
206 isFunction(val: any, msg?: string): void;
207 isNotFunction(val: any, msg?: string): void;
208
209 isObject(val: any, msg?: string): void;
210 isNotObject(val: any, msg?: string): void;
211
212 isArray(val: any, msg?: string): void;
213 isNotArray(val: any, msg?: string): void;
214
215 isString(val: any, msg?: string): void;
216 isNotString(val: any, msg?: string): void;
217
218 isNumber(val: any, msg?: string): void;
219 isNotNumber(val: any, msg?: string): void;
220
221 isBoolean(val: any, msg?: string): void;
222 isNotBoolean(val: any, msg?: string): void;
223
224 typeOf(val: any, type: string, msg?: string): void;
225 notTypeOf(val: any, type: string, msg?: string): void;
226
227 instanceOf(val: any, type: Function, msg?: string): void;
228 notInstanceOf(val: any, type: Function, msg?: string): void;
229
230 include(exp: string, inc: any, msg?: string): void;
231 include(exp: any[], inc: any, msg?: string): void;
232
233 notInclude(exp: string, inc: any, msg?: string): void;
234 notInclude(exp: any[], inc: any, msg?: string): void;
235
236 match(exp: any, re: RegExp, msg?: string): void;
237 notMatch(exp: any, re: RegExp, msg?: string): void;
238
239 property(obj: Object, prop: string, msg?: string): void;
240 notProperty(obj: Object, prop: string, msg?: string): void;
241 deepProperty(obj: Object, prop: string, msg?: string): void;
242 notDeepProperty(obj: Object, prop: string, msg?: string): void;
243
244 propertyVal(obj: Object, prop: string, val: any, msg?: string): void;
245 propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
246
247 deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void;
248 deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
249
250 lengthOf(exp: any, len: number, msg?: string): void;
251 //alias frenzy
252 throw(fn: Function, msg?: string): void;
253 throw(fn: Function, regExp: RegExp): void;
254 throw(fn: Function, errType: Function, msg?: string): void;
255 throw(fn: Function, errType: Function, regExp: RegExp): void;
256
257 throws(fn: Function, msg?: string): void;
258 throws(fn: Function, regExp: RegExp): void;
259 throws(fn: Function, errType: Function, msg?: string): void;
260 throws(fn: Function, errType: Function, regExp: RegExp): void;
261
262 Throw(fn: Function, msg?: string): void;
263 Throw(fn: Function, regExp: RegExp): void;
264 Throw(fn: Function, errType: Function, msg?: string): void;
265 Throw(fn: Function, errType: Function, regExp: RegExp): void;
266
267 doesNotThrow(fn: Function, msg?: string): void;
268 doesNotThrow(fn: Function, regExp: RegExp): void;
269 doesNotThrow(fn: Function, errType: Function, msg?: string): void;
270 doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void;
271
272 operator(val: any, operator: string, val2: any, msg?: string): void;
273 closeTo(act: number, exp: number, delta: number, msg?: string): void;
274
275 sameMembers(set1: any[], set2: any[], msg?: string): void;
276 includeMembers(set1: any[], set2: any[], msg?: string): void;
277
278 ifError(val: any, msg?: string): void;
279 }
280}
281
282declare module "chai" {
283 export = chai;
284}