|
| 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 | + |
| 6 | +declare 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 | + with: Expect; |
| 98 | + at: Expect; |
| 99 | + of: Expect; |
| 100 | + same: Expect; |
| 101 | + } |
| 102 | + |
| 103 | + interface NumericComparison { |
| 104 | + above: NumberComparer; |
| 105 | + gt: NumberComparer; |
| 106 | + greaterThan: NumberComparer; |
| 107 | + least: NumberComparer; |
| 108 | + gte: NumberComparer; |
| 109 | + below: NumberComparer; |
| 110 | + lt: NumberComparer; |
| 111 | + lessThan: NumberComparer; |
| 112 | + most: NumberComparer; |
| 113 | + lte: NumberComparer; |
| 114 | + within(start: number, finish: number, message?: string): Expect; |
| 115 | + } |
| 116 | + |
| 117 | + interface NumberComparer { |
| 118 | + (value: number, message?: string): Expect; |
| 119 | + } |
| 120 | + |
| 121 | + interface TypeComparison { |
| 122 | + (type: string, message?: string): Expect; |
| 123 | + instanceof: InstanceOf; |
| 124 | + instanceOf: InstanceOf; |
| 125 | + } |
| 126 | + |
| 127 | + interface InstanceOf { |
| 128 | + (constructor: Object, message?: string): Expect; |
| 129 | + } |
| 130 | + |
| 131 | + interface Deep { |
| 132 | + equal: Equal; |
| 133 | + property: Property; |
| 134 | + } |
| 135 | + |
| 136 | + interface Equal { |
| 137 | + (value: any, message?: string): Expect; |
| 138 | + } |
| 139 | + |
| 140 | + interface Property { |
| 141 | + (name: string, value?: any, message?: string): Expect; |
| 142 | + } |
| 143 | + |
| 144 | + interface OwnProperty { |
| 145 | + (name: string, message?: string): Expect; |
| 146 | + } |
| 147 | + |
| 148 | + interface Length extends LanguageChains, NumericComparison { |
| 149 | + (length: number, message?: string): Expect; |
| 150 | + } |
| 151 | + |
| 152 | + interface Include { |
| 153 | + (value: Object, message?: string): Expect; |
| 154 | + (value: string, message?: string): Expect; |
| 155 | + (value: number, message?: string): Expect; |
| 156 | + keys: Keys; |
| 157 | + members: Members; |
| 158 | + } |
| 159 | + |
| 160 | + interface Keys { |
| 161 | + (...keys: string[]): Expect; |
| 162 | + (keys: any[]): Expect; |
| 163 | + } |
| 164 | + |
| 165 | + interface Members { |
| 166 | + (set: any[], message?: string): Expect; |
| 167 | + } |
| 168 | + |
| 169 | + interface Throw { |
| 170 | + (): Expect; |
| 171 | + (expected: string, message?: string): Expect; |
| 172 | + (expected: RegExp, message?: string): Expect; |
| 173 | + (constructor: Error, expected?: string, message?: string): Expect; |
| 174 | + (constructor: Error, expected?: RegExp, message?: string): Expect; |
| 175 | + (constructor: Function, expected?: string, message?: string): Expect; |
| 176 | + (constructor: Function, expected?: RegExp, message?: string): Expect; |
| 177 | + } |
| 178 | + |
| 179 | + export interface Assert { |
| 180 | + (express: any, msg?: string):void; |
| 181 | + |
| 182 | + fail(actual?: any, expected?: any, msg?: string, operator?: string):void; |
| 183 | + |
| 184 | + ok(val: any, msg?: string):void; |
| 185 | + notOk(val: any, msg?: string):void; |
| 186 | + |
| 187 | + equal(act: any, exp: any, msg?: string):void; |
| 188 | + notEqual(act: any, exp: any, msg?: string):void; |
| 189 | + |
| 190 | + strictEqual(act: any, exp: any, msg?: string):void; |
| 191 | + notStrictEqual(act: any, exp: any, msg?: string):void; |
| 192 | + |
| 193 | + deepEqual(act: any, exp: any, msg?: string):void; |
| 194 | + notDeepEqual(act: any, exp: any, msg?: string):void; |
| 195 | + |
| 196 | + isTrue(val: any, msg?: string):void; |
| 197 | + isFalse(val: any, msg?: string):void; |
| 198 | + |
| 199 | + isNull(val: any, msg?: string):void; |
| 200 | + isNotNull(val: any, msg?: string):void; |
| 201 | + |
| 202 | + isUndefined(val: any, msg?: string):void; |
| 203 | + isDefined(val: any, msg?: string):void; |
| 204 | + |
| 205 | + isFunction(val: any, msg?: string):void; |
| 206 | + isNotFunction(val: any, msg?: string):void; |
| 207 | + |
| 208 | + isObject(val: any, msg?: string):void; |
| 209 | + isNotObject(val: any, msg?: string):void; |
| 210 | + |
| 211 | + isArray(val: any, msg?: string):void; |
| 212 | + isNotArray(val: any, msg?: string):void; |
| 213 | + |
| 214 | + isString(val: any, msg?: string):void; |
| 215 | + isNotString(val: any, msg?: string):void; |
| 216 | + |
| 217 | + isNumber(val: any, msg?: string):void; |
| 218 | + isNotNumber(val: any, msg?: string):void; |
| 219 | + |
| 220 | + isBoolean(val: any, msg?: string):void; |
| 221 | + isNotBoolean(val: any, msg?: string):void; |
| 222 | + |
| 223 | + typeOf(val: any, type: string, msg?: string):void; |
| 224 | + notTypeOf(val: any, type: string, msg?: string):void; |
| 225 | + |
| 226 | + instanceOf(val: any, type: Function, msg?: string):void; |
| 227 | + notInstanceOf(val: any, type: Function, msg?: string):void; |
| 228 | + |
| 229 | + include(exp: string, inc: any, msg?: string):void; |
| 230 | + include(exp: any[], inc: any, msg?: string):void; |
| 231 | + |
| 232 | + notInclude(exp: string, inc: any, msg?: string):void; |
| 233 | + notInclude(exp: any[], inc: any, msg?: string):void; |
| 234 | + |
| 235 | + match(exp: any, re: RegExp, msg?: string):void; |
| 236 | + notMatch(exp: any, re: RegExp, msg?: string):void; |
| 237 | + |
| 238 | + property(obj: Object, prop: string, msg?: string):void; |
| 239 | + notProperty(obj: Object, prop: string, msg?: string):void; |
| 240 | + deepProperty(obj: Object, prop: string, msg?: string):void; |
| 241 | + notDeepProperty(obj: Object, prop: string, msg?: string):void; |
| 242 | + |
| 243 | + propertyVal(obj: Object, prop: string, val: any, msg?: string):void; |
| 244 | + propertyNotVal(obj: Object, prop: string, val: any, msg?: string):void; |
| 245 | + |
| 246 | + deepPropertyVal(obj: Object, prop: string, val: any, msg?: string):void; |
| 247 | + deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string):void; |
| 248 | + |
| 249 | + lengthOf(exp: any, len: number, msg?: string):void; |
| 250 | + //alias frenzy |
| 251 | + throw(fn: Function, msg?: string):void; |
| 252 | + throw(fn: Function, regExp: RegExp):void; |
| 253 | + throw(fn: Function, errType: Function, msg?: string):void; |
| 254 | + throw(fn: Function, errType: Function, regExp: RegExp):void; |
| 255 | + |
| 256 | + throws(fn: Function, msg?: string):void; |
| 257 | + throws(fn: Function, regExp: RegExp):void; |
| 258 | + throws(fn: Function, errType: Function, msg?: string):void; |
| 259 | + throws(fn: Function, errType: Function, regExp: RegExp):void; |
| 260 | + |
| 261 | + Throw(fn: Function, msg?: string):void; |
| 262 | + Throw(fn: Function, regExp: RegExp):void; |
| 263 | + Throw(fn: Function, errType: Function, msg?: string):void; |
| 264 | + Throw(fn: Function, errType: Function, regExp: RegExp):void; |
| 265 | + |
| 266 | + doesNotThrow(fn: Function, msg?: string):void; |
| 267 | + doesNotThrow(fn: Function, regExp: RegExp):void; |
| 268 | + doesNotThrow(fn: Function, errType: Function, msg?: string):void; |
| 269 | + doesNotThrow(fn: Function, errType: Function, regExp: RegExp):void; |
| 270 | + |
| 271 | + operator(val: any, operator: string, val2: any, msg?: string):void; |
| 272 | + closeTo(act: number, exp: number, delta: number, msg?: string):void; |
| 273 | + |
| 274 | + sameMembers(set1: any[], set2: any[], msg?: string):void; |
| 275 | + includeMembers(set1: any[], set2: any[], msg?: string):void; |
| 276 | + |
| 277 | + ifError(val: any, msg?: string):void; |
| 278 | + } |
| 279 | +} |
| 280 | + |
| 281 | +declare module "chai" { |
| 282 | +export = chai; |
| 283 | +} |
0 commit comments