|
| 1 | +declare module 'chai' { |
| 2 | + declare type ExpectChain<T> = { |
| 3 | + and: ExpectChain<T>, |
| 4 | + at: ExpectChain<T>, |
| 5 | + be: ExpectChain<T>, |
| 6 | + been: ExpectChain<T>, |
| 7 | + have: ExpectChain<T>, |
| 8 | + has: ExpectChain<T>, |
| 9 | + is: ExpectChain<T>, |
| 10 | + of: ExpectChain<T>, |
| 11 | + same: ExpectChain<T>, |
| 12 | + that: ExpectChain<T>, |
| 13 | + to: ExpectChain<T>, |
| 14 | + which: ExpectChain<T>, |
| 15 | + with: ExpectChain<T>, |
| 16 | + not: ExpectChain<T>, |
| 17 | + deep: ExpectChain<T>, |
| 18 | + any: ExpectChain<T>, |
| 19 | + all: ExpectChain<T>, |
| 20 | + own: ExpectChain<T>, |
| 21 | + a: ExpectChain<T> & ((type: string, message?: string) => ExpectChain<T>), |
| 22 | + an: ExpectChain<T> & ((type: string, message?: string) => ExpectChain<T>), |
| 23 | + include: ExpectChain<T> & |
| 24 | + ((value: mixed, message?: string) => ExpectChain<T>), |
| 25 | + includes: ExpectChain<T> & |
| 26 | + ((value: mixed, message?: string) => ExpectChain<T>), |
| 27 | + contain: ExpectChain<T> & |
| 28 | + ((value: mixed, message?: string) => ExpectChain<T>), |
| 29 | + contains: ExpectChain<T> & |
| 30 | + ((value: mixed, message?: string) => ExpectChain<T>), |
| 31 | + eq: (value: T, message?: string) => ExpectChain<T>, |
| 32 | + eql: (value: T, message?: string) => ExpectChain<T>, |
| 33 | + equal: (value: T, message?: string) => ExpectChain<T>, |
| 34 | + equals: (value: T, message?: string) => ExpectChain<T>, |
| 35 | + above: (value: T & number, message?: string) => ExpectChain<T>, |
| 36 | + gt: (value: T & number, message?: string) => ExpectChain<T>, |
| 37 | + greaterThan: (value: T & number, message?: string) => ExpectChain<T>, |
| 38 | + least: (value: T & number, message?: string) => ExpectChain<T>, |
| 39 | + below: (value: T & number, message?: string) => ExpectChain<T>, |
| 40 | + lessThan: (value: T & number, message?: string) => ExpectChain<T>, |
| 41 | + lt: (value: T & number, message?: string) => ExpectChain<T>, |
| 42 | + most: (value: T & number, message?: string) => ExpectChain<T>, |
| 43 | + within: ( |
| 44 | + start: T & number, |
| 45 | + finish: T & number, |
| 46 | + message?: string, |
| 47 | + ) => ExpectChain<T>, |
| 48 | + instanceof: (constructor: mixed, message?: string) => ExpectChain<T>, |
| 49 | + instanceOf: (constructor: mixed, message?: string) => ExpectChain<T>, |
| 50 | + nested: ExpectChain<T>, |
| 51 | + property: <P>( |
| 52 | + name: string, |
| 53 | + value?: P, |
| 54 | + message?: string, |
| 55 | + ) => ExpectChain<P> & ((name: string) => ExpectChain<mixed>), |
| 56 | + length: ExpectChain<number> & |
| 57 | + ((value: number, message?: string) => ExpectChain<T>), |
| 58 | + lengthOf: ExpectChain<number> & |
| 59 | + ((value: number, message?: string) => ExpectChain<T>), |
| 60 | + match: (regex: RegExp, message?: string) => ExpectChain<T>, |
| 61 | + matches: (regex: RegExp, message?: string) => ExpectChain<T>, |
| 62 | + string: (string: string, message?: string) => ExpectChain<T>, |
| 63 | + key: (key: string) => ExpectChain<T>, |
| 64 | + keys: ( |
| 65 | + key: string | Array<string>, |
| 66 | + ...keys: Array<string> |
| 67 | + ) => ExpectChain<T>, |
| 68 | + throw: <E>( |
| 69 | + err?: Class<E> | Error | RegExp | string, |
| 70 | + errMsgMatcher?: RegExp | string, |
| 71 | + msg?: string, |
| 72 | + ) => ExpectChain<T>, |
| 73 | + respondTo: (method: string, message?: string) => ExpectChain<T>, |
| 74 | + itself: ExpectChain<T>, |
| 75 | + satisfy: ( |
| 76 | + method: (value: T) => boolean, |
| 77 | + message?: string, |
| 78 | + ) => ExpectChain<T>, |
| 79 | + closeTo: ( |
| 80 | + expected: T & number, |
| 81 | + delta: number, |
| 82 | + message?: string, |
| 83 | + ) => ExpectChain<T>, |
| 84 | + members: (set: mixed, message?: string) => ExpectChain<T>, |
| 85 | + oneOf: (list: Array<T>, message?: string) => ExpectChain<T>, |
| 86 | + change: (obj: mixed, key: string, message?: string) => ExpectChain<T>, |
| 87 | + increase: (obj: mixed, key: string, message?: string) => ExpectChain<T>, |
| 88 | + decrease: (obj: mixed, key: string, message?: string) => ExpectChain<T>, |
| 89 | + by: (delta: number, message?: string) => ExpectChain<T>, |
| 90 | + ordered: ExpectChain<T>, |
| 91 | + // dirty-chai |
| 92 | + ok: () => ExpectChain<T>, |
| 93 | + true: () => ExpectChain<T>, |
| 94 | + false: () => ExpectChain<T>, |
| 95 | + null: () => ExpectChain<T>, |
| 96 | + undefined: () => ExpectChain<T>, |
| 97 | + exist: () => ExpectChain<T>, |
| 98 | + empty: () => ExpectChain<T>, |
| 99 | + extensible: () => ExpectChain<T>, |
| 100 | + sealed: () => ExpectChain<T>, |
| 101 | + frozen: () => ExpectChain<T>, |
| 102 | + NaN: () => ExpectChain<T>, |
| 103 | + // chai-immutable |
| 104 | + size: (n: number) => ExpectChain<T>, |
| 105 | + // sinon-chai |
| 106 | + called: () => ExpectChain<T>, |
| 107 | + callCount: (n: number) => ExpectChain<T>, |
| 108 | + calledOnce: () => ExpectChain<T>, |
| 109 | + calledTwice: () => ExpectChain<T>, |
| 110 | + calledThrice: () => ExpectChain<T>, |
| 111 | + calledBefore: (spy: mixed) => ExpectChain<T>, |
| 112 | + calledAfter: (spy: mixed) => ExpectChain<T>, |
| 113 | + calledImmediatelyBefore: (spy: mixed) => ExpectChain<T>, |
| 114 | + calledImmediatelyAfter: (spy: mixed) => ExpectChain<T>, |
| 115 | + calledWith: (...args: Array<mixed>) => ExpectChain<T>, |
| 116 | + calledOnceWith: (...args: Array<mixed>) => ExpectChain<T>, |
| 117 | + calledWithMatch: (...args: Array<mixed>) => ExpectChain<T>, |
| 118 | + calledWithExactly: (...args: Array<mixed>) => ExpectChain<T>, |
| 119 | + calledOnceWithExactly: (...args: Array<mixed>) => ExpectChain<T>, |
| 120 | + returned: (returnVal: mixed) => ExpectChain<T>, |
| 121 | + alwaysReturned: (returnVal: mixed) => ExpectChain<T>, |
| 122 | + // chai-as-promised |
| 123 | + eventually: ExpectChain<T>, |
| 124 | + resolvedWith: (value: mixed) => Promise<mixed> & ExpectChain<T>, |
| 125 | + resolved: () => Promise<mixed> & ExpectChain<T>, |
| 126 | + rejectedWith: ( |
| 127 | + value: mixed, |
| 128 | + errMsgMatcher?: RegExp | string, |
| 129 | + msg?: string, |
| 130 | + ) => Promise<mixed> & ExpectChain<T>, |
| 131 | + rejected: () => Promise<mixed> & ExpectChain<T>, |
| 132 | + notify: (callback: () => mixed) => ExpectChain<T>, |
| 133 | + fulfilled: () => Promise<mixed> & ExpectChain<T>, |
| 134 | + // chai-subset |
| 135 | + containSubset: (obj: { ... } | Array<{ ... }>) => ExpectChain<T>, |
| 136 | + // chai-redux-mock-store |
| 137 | + dispatchedActions: ( |
| 138 | + actions: Array<{ ... } | ((action: { ... }) => any)>, |
| 139 | + ) => ExpectChain<T>, |
| 140 | + dispatchedTypes: (actions: Array<string>) => ExpectChain<T>, |
| 141 | + // chai-enzyme |
| 142 | + attr: (key: string, val?: any) => ExpectChain<T>, |
| 143 | + data: (key: string, val?: any) => ExpectChain<T>, |
| 144 | + prop: (key: string, val?: any) => ExpectChain<T>, |
| 145 | + state: (key: string, val?: any) => ExpectChain<T>, |
| 146 | + value: (val: string) => ExpectChain<T>, |
| 147 | + className: (val: string) => ExpectChain<T>, |
| 148 | + text: (val: string) => ExpectChain<T>, |
| 149 | + // chai-karma-snapshot |
| 150 | + matchSnapshot: (lang?: any, update?: boolean, msg?: any) => ExpectChain<T>, |
| 151 | + ... |
| 152 | + }; |
| 153 | + |
| 154 | + declare var expect: { |
| 155 | + <T>(actual: T, message?: string): ExpectChain<T>, |
| 156 | + fail: ((message?: string) => void) & |
| 157 | + (( |
| 158 | + actual: any, |
| 159 | + expected: any, |
| 160 | + message?: string, |
| 161 | + operator?: string, |
| 162 | + ) => void), |
| 163 | + ... |
| 164 | + }; |
| 165 | + |
| 166 | + declare function use(plugin: (chai: Object, utils: Object) => void): void; |
| 167 | + |
| 168 | + declare class assert { |
| 169 | + static (expression: mixed, message?: string): void; |
| 170 | + static fail( |
| 171 | + actual: mixed, |
| 172 | + expected: mixed, |
| 173 | + message?: string, |
| 174 | + operator?: string, |
| 175 | + ): void; |
| 176 | + |
| 177 | + static isOk(object: mixed, message?: string): void; |
| 178 | + static isNotOk(object: mixed, message?: string): void; |
| 179 | + |
| 180 | + static empty(object: mixed, message?: string): void; |
| 181 | + static isEmpty(object: mixed, message?: string): void; |
| 182 | + static notEmpty(object: mixed, message?: string): void; |
| 183 | + static isNotEmpty(object: mixed, message?: string): void; |
| 184 | + |
| 185 | + static equal(actual: mixed, expected: mixed, message?: string): void; |
| 186 | + static notEqual(actual: mixed, expected: mixed, message?: string): void; |
| 187 | + |
| 188 | + static strictEqual(act: mixed, exp: mixed, msg?: string): void; |
| 189 | + static notStrictEqual(act: mixed, exp: mixed, msg?: string): void; |
| 190 | + |
| 191 | + static deepEqual(act: mixed, exp: mixed, msg?: string): void; |
| 192 | + static notDeepEqual(act: mixed, exp: mixed, msg?: string): void; |
| 193 | + |
| 194 | + static ok(val: mixed, msg?: string): void; |
| 195 | + static isTrue(val: mixed, msg?: string): void; |
| 196 | + static isNotTrue(val: mixed, msg?: string): void; |
| 197 | + static isFalse(val: mixed, msg?: string): void; |
| 198 | + static isNotFalse(val: mixed, msg?: string): void; |
| 199 | + |
| 200 | + static isNull(val: mixed, msg?: string): void; |
| 201 | + static isNotNull(val: mixed, msg?: string): void; |
| 202 | + |
| 203 | + static isUndefined(val: mixed, msg?: string): void; |
| 204 | + static isDefined(val: mixed, msg?: string): void; |
| 205 | + |
| 206 | + static isNaN(val: mixed, msg?: string): void; |
| 207 | + static isNotNaN(val: mixed, msg?: string): void; |
| 208 | + |
| 209 | + static isAbove(val: number, abv: number, msg?: string): void; |
| 210 | + static isBelow(val: number, blw: number, msg?: string): void; |
| 211 | + |
| 212 | + static exists(val: mixed, msg?: string): void; |
| 213 | + static notExists(val: mixed, msg?: string): void; |
| 214 | + |
| 215 | + static isAtMost(val: number, atmst: number, msg?: string): void; |
| 216 | + static isAtLeast(val: number, atlst: number, msg?: string): void; |
| 217 | + |
| 218 | + static isFunction(val: mixed, msg?: string): void; |
| 219 | + static isNotFunction(val: mixed, msg?: string): void; |
| 220 | + |
| 221 | + static isObject(val: mixed, msg?: string): void; |
| 222 | + static isNotObject(val: mixed, msg?: string): void; |
| 223 | + |
| 224 | + static isArray(val: mixed, msg?: string): void; |
| 225 | + static isNotArray(val: mixed, msg?: string): void; |
| 226 | + |
| 227 | + static isString(val: mixed, msg?: string): void; |
| 228 | + static isNotString(val: mixed, msg?: string): void; |
| 229 | + |
| 230 | + static isNumber(val: mixed, msg?: string): void; |
| 231 | + static isNotNumber(val: mixed, msg?: string): void; |
| 232 | + |
| 233 | + static isBoolean(val: mixed, msg?: string): void; |
| 234 | + static isNotBoolean(val: mixed, msg?: string): void; |
| 235 | + |
| 236 | + static typeOf(val: mixed, type: string, msg?: string): void; |
| 237 | + static notTypeOf(val: mixed, type: string, msg?: string): void; |
| 238 | + |
| 239 | + static instanceOf(val: mixed, constructor: Class<*>, msg?: string): void; |
| 240 | + static notInstanceOf(val: mixed, constructor: Class<*>, msg?: string): void; |
| 241 | + |
| 242 | + static include(exp: string, inc: mixed, msg?: string): void; |
| 243 | + static include<T>(exp: Array<T>, inc: T, msg?: string): void; |
| 244 | + |
| 245 | + static notInclude(exp: string, inc: mixed, msg?: string): void; |
| 246 | + static notInclude<T>(exp: Array<T>, inc: T, msg?: string): void; |
| 247 | + |
| 248 | + static deepInclude<T>( |
| 249 | + haystack: T[] | string, |
| 250 | + needle: $Shape<T>, |
| 251 | + msg?: string, |
| 252 | + ): void; |
| 253 | + static notDeepInclude<T>( |
| 254 | + haystack: T[] | string, |
| 255 | + needle: $Shape<T>, |
| 256 | + msg?: string, |
| 257 | + ): void; |
| 258 | + |
| 259 | + static match(exp: mixed, re: RegExp, msg?: string): void; |
| 260 | + static notMatch(exp: mixed, re: RegExp, msg?: string): void; |
| 261 | + |
| 262 | + static property(obj: Object, prop: string, msg?: string): void; |
| 263 | + static notProperty(obj: Object, prop: string, msg?: string): void; |
| 264 | + static deepProperty(obj: Object, prop: string, msg?: string): void; |
| 265 | + static notDeepProperty(obj: Object, prop: string, msg?: string): void; |
| 266 | + |
| 267 | + static propertyVal( |
| 268 | + obj: Object, |
| 269 | + prop: string, |
| 270 | + val: mixed, |
| 271 | + msg?: string, |
| 272 | + ): void; |
| 273 | + static propertyNotVal( |
| 274 | + obj: Object, |
| 275 | + prop: string, |
| 276 | + val: mixed, |
| 277 | + msg?: string, |
| 278 | + ): void; |
| 279 | + |
| 280 | + static deepPropertyVal( |
| 281 | + obj: Object, |
| 282 | + prop: string, |
| 283 | + val: mixed, |
| 284 | + msg?: string, |
| 285 | + ): void; |
| 286 | + static deepPropertyNotVal( |
| 287 | + obj: Object, |
| 288 | + prop: string, |
| 289 | + val: mixed, |
| 290 | + msg?: string, |
| 291 | + ): void; |
| 292 | + |
| 293 | + static lengthOf(exp: mixed, len: number, msg?: string): void; |
| 294 | + |
| 295 | + static throws<E>( |
| 296 | + func: () => any, |
| 297 | + err?: Class<E> | Error | RegExp | string, |
| 298 | + errorMsgMatcher?: string | RegExp, |
| 299 | + msg?: string, |
| 300 | + ): void; |
| 301 | + static doesNotThrow<E>( |
| 302 | + func: () => any, |
| 303 | + err?: Class<E> | Error | RegExp | string, |
| 304 | + errorMsgMatcher?: string | RegExp, |
| 305 | + msg?: string, |
| 306 | + ): void; |
| 307 | + |
| 308 | + static closeTo( |
| 309 | + actual: number, |
| 310 | + expected: number, |
| 311 | + delta: number, |
| 312 | + msg?: string, |
| 313 | + ): void; |
| 314 | + static approximately( |
| 315 | + actual: number, |
| 316 | + expected: number, |
| 317 | + delta: number, |
| 318 | + msg?: string, |
| 319 | + ): void; |
| 320 | + |
| 321 | + // chai-immutable |
| 322 | + static sizeOf(val: mixed, length: number): void; |
| 323 | + } |
| 324 | + |
| 325 | + declare var config: { |
| 326 | + includeStack: boolean, |
| 327 | + showDiff: boolean, |
| 328 | + truncateThreshold: number, |
| 329 | + ... |
| 330 | + }; |
| 331 | +} |
0 commit comments