index.d.ts 13 KB

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