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