UNPKG

13.2 kBTypeScriptView Raw
1// Generated by typings
2// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/chai/chai.d.ts
3// Type definitions for chai 3.4.0
4// Project: http://chaijs.com/
5// Definitions by: Jed Mao <https://github.com/jedmao/>,
6// Bart van der Schoor <https://github.com/Bartvds>,
7// Andrew Brown <https://github.com/AGBrown>,
8// Olivier Chevet <https://github.com/olivr70>,
9// Matt Wistrand <https://github.com/mwistrand>
10// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
11
12// <reference path="../assertion-error/assertion-error.d.ts"/>
13
14declare namespace Chai {
15
16 interface ChaiStatic {
17 expect: ExpectStatic;
18 should(): Should;
19 /**
20 * Provides a way to extend the internals of Chai
21 */
22 use(fn: (chai: any, utils: any) => void): ChaiStatic;
23 assert: AssertStatic;
24 config: Config;
25 AssertionError: typeof AssertionError;
26 }
27
28 export interface ExpectStatic extends AssertionStatic {
29 fail(actual?: any, expected?: any, message?: string, operator?: string): void;
30 }
31
32 export interface AssertStatic extends Assert {
33 }
34
35 export interface AssertionStatic {
36 (target: any, message?: string): Assertion;
37 }
38
39 interface ShouldAssertion {
40 equal(value1: any, value2: any, message?: string): void;
41 Throw: ShouldThrow;
42 throw: ShouldThrow;
43 exist(value: any, message?: string): void;
44 }
45
46 interface Should extends ShouldAssertion {
47 not: ShouldAssertion;
48 fail(actual: any, expected: any, message?: string, operator?: string): void;
49 }
50
51 interface ShouldThrow {
52 (actual: Function): void;
53 (actual: Function, expected: string|RegExp, message?: string): void;
54 (actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void;
55 }
56
57 interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
58 not: Assertion;
59 deep: Deep;
60 any: KeyFilter;
61 all: KeyFilter;
62 a: TypeComparison;
63 an: TypeComparison;
64 include: Include;
65 includes: Include;
66 contain: Include;
67 contains: Include;
68 ok: Assertion;
69 true: Assertion;
70 false: Assertion;
71 null: Assertion;
72 undefined: Assertion;
73 NaN: Assertion;
74 exist: Assertion;
75 empty: Assertion;
76 arguments: Assertion;
77 Arguments: Assertion;
78 equal: Equal;
79 equals: Equal;
80 eq: Equal;
81 eql: Equal;
82 eqls: Equal;
83 property: Property;
84 ownProperty: OwnProperty;
85 haveOwnProperty: OwnProperty;
86 ownPropertyDescriptor: OwnPropertyDescriptor;
87 haveOwnPropertyDescriptor: OwnPropertyDescriptor;
88 length: Length;
89 lengthOf: Length;
90 match: Match;
91 matches: Match;
92 string(string: string, message?: string): Assertion;
93 keys: Keys;
94 key(string: string): Assertion;
95 throw: Throw;
96 throws: Throw;
97 Throw: Throw;
98 respondTo: RespondTo;
99 respondsTo: RespondTo;
100 itself: Assertion;
101 satisfy: Satisfy;
102 satisfies: Satisfy;
103 closeTo: CloseTo;
104 approximately: CloseTo;
105 members: Members;
106 increase: PropertyChange;
107 increases: PropertyChange;
108 decrease: PropertyChange;
109 decreases: PropertyChange;
110 change: PropertyChange;
111 changes: PropertyChange;
112 extensible: Assertion;
113 sealed: Assertion;
114 frozen: Assertion;
115 oneOf(list: any[], message?: string): Assertion;
116 }
117
118 interface LanguageChains {
119 to: Assertion;
120 be: Assertion;
121 been: Assertion;
122 is: Assertion;
123 that: Assertion;
124 which: Assertion;
125 and: Assertion;
126 has: Assertion;
127 have: Assertion;
128 with: Assertion;
129 at: Assertion;
130 of: Assertion;
131 same: Assertion;
132 }
133
134 interface NumericComparison {
135 above: NumberComparer;
136 gt: NumberComparer;
137 greaterThan: NumberComparer;
138 least: NumberComparer;
139 gte: NumberComparer;
140 below: NumberComparer;
141 lt: NumberComparer;
142 lessThan: NumberComparer;
143 most: NumberComparer;
144 lte: NumberComparer;
145 within(start: number, finish: number, message?: string): Assertion;
146 }
147
148 interface NumberComparer {
149 (value: number, message?: string): Assertion;
150 }
151
152 interface TypeComparison {
153 (type: string, message?: string): Assertion;
154 instanceof: InstanceOf;
155 instanceOf: InstanceOf;
156 }
157
158 interface InstanceOf {
159 (constructor: Object, message?: string): Assertion;
160 }
161
162 interface CloseTo {
163 (expected: number, delta: number, message?: string): Assertion;
164 }
165
166 interface Deep {
167 equal: Equal;
168 include: Include;
169 property: Property;
170 members: Members;
171 }
172
173 interface KeyFilter {
174 keys: Keys;
175 }
176
177 interface Equal {
178 (value: any, message?: string): Assertion;
179 }
180
181 interface Property {
182 (name: string, value?: any, message?: string): Assertion;
183 }
184
185 interface OwnProperty {
186 (name: string, message?: string): Assertion;
187 }
188
189 interface OwnPropertyDescriptor {
190 (name: string, descriptor: PropertyDescriptor, message?: string): Assertion;
191 (name: string, message?: string): Assertion;
192 }
193
194 interface Length extends LanguageChains, NumericComparison {
195 (length: number, message?: string): Assertion;
196 }
197
198 interface Include {
199 (value: Object, message?: string): Assertion;
200 (value: string, message?: string): Assertion;
201 (value: number, message?: string): Assertion;
202 keys: Keys;
203 members: Members;
204 any: KeyFilter;
205 all: KeyFilter;
206 }
207
208 interface Match {
209 (regexp: RegExp|string, message?: string): Assertion;
210 }
211
212 interface Keys {
213 (...keys: string[]): Assertion;
214 (keys: any[]): Assertion;
215 (keys: Object): Assertion;
216 }
217
218 interface Throw {
219 (): Assertion;
220 (expected: string, message?: string): Assertion;
221 (expected: RegExp, message?: string): Assertion;
222 (constructor: Error, expected?: string, message?: string): Assertion;
223 (constructor: Error, expected?: RegExp, message?: string): Assertion;
224 (constructor: Function, expected?: string, message?: string): Assertion;
225 (constructor: Function, expected?: RegExp, message?: string): Assertion;
226 }
227
228 interface RespondTo {
229 (method: string, message?: string): Assertion;
230 }
231
232 interface Satisfy {
233 (matcher: Function, message?: string): Assertion;
234 }
235
236 interface Members {
237 (set: any[], message?: string): Assertion;
238 }
239
240 interface PropertyChange {
241 (object: Object, prop: string, msg?: string): Assertion;
242 }
243
244 export interface Assert {
245 /**
246 * @param expression Expression to test for truthiness.
247 * @param message Message to display on error.
248 */
249 (expression: any, message?: string): void;
250
251 fail(actual?: any, expected?: any, msg?: string, operator?: string): void;
252
253 ok(val: any, msg?: string): void;
254 isOk(val: any, msg?: string): void;
255 notOk(val: any, msg?: string): void;
256 isNotOk(val: any, msg?: string): void;
257
258 equal(act: any, exp: any, msg?: string): void;
259 notEqual(act: any, exp: any, msg?: string): void;
260
261 strictEqual(act: any, exp: any, msg?: string): void;
262 notStrictEqual(act: any, exp: any, msg?: string): void;
263
264 deepEqual(act: any, exp: any, msg?: string): void;
265 notDeepEqual(act: any, exp: any, msg?: string): void;
266
267 isTrue(val: any, msg?: string): void;
268 isFalse(val: any, msg?: string): void;
269
270 isNotTrue(val: any, msg?: string): void;
271 isNotFalse(val: any, msg?: string): void;
272
273 isNull(val: any, msg?: string): void;
274 isNotNull(val: any, msg?: string): void;
275
276 isUndefined(val: any, msg?: string): void;
277 isDefined(val: any, msg?: string): void;
278
279 isNaN(val: any, msg?: string): void;
280 isNotNaN(val: any, msg?: string): void;
281
282 isAbove(val: number, abv: number, msg?: string): void;
283 isBelow(val: number, blw: number, msg?: string): void;
284
285 isAtLeast(val: number, atlst: number, msg?: string): void;
286 isAtMost(val: number, atmst: number, msg?: string): void;
287
288 isFunction(val: any, msg?: string): void;
289 isNotFunction(val: any, msg?: string): void;
290
291 isObject(val: any, msg?: string): void;
292 isNotObject(val: any, msg?: string): void;
293
294 isArray(val: any, msg?: string): void;
295 isNotArray(val: any, msg?: string): void;
296
297 isString(val: any, msg?: string): void;
298 isNotString(val: any, msg?: string): void;
299
300 isNumber(val: any, msg?: string): void;
301 isNotNumber(val: any, msg?: string): void;
302
303 isBoolean(val: any, msg?: string): void;
304 isNotBoolean(val: any, msg?: string): void;
305
306 typeOf(val: any, type: string, msg?: string): void;
307 notTypeOf(val: any, type: string, msg?: string): void;
308
309 instanceOf(val: any, type: Function, msg?: string): void;
310 notInstanceOf(val: any, type: Function, msg?: string): void;
311
312 include(exp: string, inc: any, msg?: string): void;
313 include(exp: any[], inc: any, msg?: string): void;
314
315 notInclude(exp: string, inc: any, msg?: string): void;
316 notInclude(exp: any[], inc: any, msg?: string): void;
317
318 match(exp: any, re: RegExp, msg?: string): void;
319 notMatch(exp: any, re: RegExp, msg?: string): void;
320
321 property(obj: Object, prop: string, msg?: string): void;
322 notProperty(obj: Object, prop: string, msg?: string): void;
323 deepProperty(obj: Object, prop: string, msg?: string): void;
324 notDeepProperty(obj: Object, prop: string, msg?: string): void;
325
326 propertyVal(obj: Object, prop: string, val: any, msg?: string): void;
327 propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
328
329 deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void;
330 deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
331
332 lengthOf(exp: any, len: number, msg?: string): void;
333 //alias frenzy
334 throw(fn: Function, msg?: string): void;
335 throw(fn: Function, regExp: RegExp): void;
336 throw(fn: Function, errType: Function, msg?: string): void;
337 throw(fn: Function, errType: Function, regExp: RegExp): void;
338
339 throws(fn: Function, msg?: string): void;
340 throws(fn: Function, regExp: RegExp): void;
341 throws(fn: Function, errType: Function, msg?: string): void;
342 throws(fn: Function, errType: Function, regExp: RegExp): void;
343
344 Throw(fn: Function, msg?: string): void;
345 Throw(fn: Function, regExp: RegExp): void;
346 Throw(fn: Function, errType: Function, msg?: string): void;
347 Throw(fn: Function, errType: Function, regExp: RegExp): void;
348
349 doesNotThrow(fn: Function, msg?: string): void;
350 doesNotThrow(fn: Function, regExp: RegExp): void;
351 doesNotThrow(fn: Function, errType: Function, msg?: string): void;
352 doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void;
353
354 operator(val: any, operator: string, val2: any, msg?: string): void;
355 closeTo(act: number, exp: number, delta: number, msg?: string): void;
356 approximately(act: number, exp: number, delta: number, msg?: string): void;
357
358 sameMembers(set1: any[], set2: any[], msg?: string): void;
359 sameDeepMembers(set1: any[], set2: any[], msg?: string): void;
360 includeMembers(superset: any[], subset: any[], msg?: string): void;
361
362 ifError(val: any, msg?: string): void;
363
364 isExtensible(obj: {}, msg?: string): void;
365 extensible(obj: {}, msg?: string): void;
366 isNotExtensible(obj: {}, msg?: string): void;
367 notExtensible(obj: {}, msg?: string): void;
368
369 isSealed(obj: {}, msg?: string): void;
370 sealed(obj: {}, msg?: string): void;
371 isNotSealed(obj: {}, msg?: string): void;
372 notSealed(obj: {}, msg?: string): void;
373
374 isFrozen(obj: Object, msg?: string): void;
375 frozen(obj: Object, msg?: string): void;
376 isNotFrozen(obj: Object, msg?: string): void;
377 notFrozen(obj: Object, msg?: string): void;
378
379 oneOf(inList: any, list: any[], msg?: string): void;
380 }
381
382 export interface Config {
383 includeStack: boolean;
384 }
385
386 export class AssertionError {
387 constructor(message: string, _props?: any, ssf?: Function);
388 name: string;
389 message: string;
390 showDiff: boolean;
391 stack: string;
392 }
393}
394
395declare var chai: Chai.ChaiStatic;
396
397declare module "chai" {
398 export = chai;
399}
400
401interface Object {
402 should: Chai.Assertion;
403}
\No newline at end of file