index.d.ts 13 KB

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