Aucune description

index.d.ts 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. // Generated by typings
  2. // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/c49913aa9ea419ea46c1c684e488cf2a10303b1a/jasmine/jasmine.d.ts
  3. declare function describe(description: string, specDefinitions: () => void): void;
  4. declare function fdescribe(description: string, specDefinitions: () => void): void;
  5. declare function xdescribe(description: string, specDefinitions: () => void): void;
  6. declare function it(expectation: string, assertion?: () => void, timeout?: number): void;
  7. declare function it(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
  8. declare function fit(expectation: string, assertion?: () => void, timeout?: number): void;
  9. declare function fit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
  10. declare function xit(expectation: string, assertion?: () => void, timeout?: number): void;
  11. declare function xit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
  12. /** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */
  13. declare function pending(reason?: string): void;
  14. declare function beforeEach(action: () => void, timeout?: number): void;
  15. declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void;
  16. declare function afterEach(action: () => void, timeout?: number): void;
  17. declare function afterEach(action: (done: DoneFn) => void, timeout?: number): void;
  18. declare function beforeAll(action: () => void, timeout?: number): void;
  19. declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void;
  20. declare function afterAll(action: () => void, timeout?: number): void;
  21. declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void;
  22. declare function expect(spy: Function): jasmine.Matchers;
  23. declare function expect(actual: any): jasmine.Matchers;
  24. declare function fail(e?: any): void;
  25. /** Action method that should be called when the async work is complete */
  26. interface DoneFn extends Function {
  27. (): void;
  28. /** fails the spec and indicates that it has completed. If the message is an Error, Error.message is used */
  29. fail: (message?: Error|string) => void;
  30. }
  31. declare function spyOn(object: any, method: string): jasmine.Spy;
  32. declare function runs(asyncMethod: Function): void;
  33. declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void;
  34. declare function waits(timeout?: number): void;
  35. declare namespace jasmine {
  36. var clock: () => Clock;
  37. function any(aclass: any): Any;
  38. function anything(): Any;
  39. function arrayContaining(sample: any[]): ArrayContaining;
  40. function objectContaining(sample: any): ObjectContaining;
  41. function createSpy(name: string, originalFn?: Function): Spy;
  42. function createSpyObj(baseName: string, methodNames: any[]): any;
  43. function createSpyObj<T>(baseName: string, methodNames: any[]): T;
  44. function pp(value: any): string;
  45. function getEnv(): Env;
  46. function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
  47. function addMatchers(matchers: CustomMatcherFactories): void;
  48. function stringMatching(str: string): Any;
  49. function stringMatching(str: RegExp): Any;
  50. interface Any {
  51. new (expectedClass: any): any;
  52. jasmineMatches(other: any): boolean;
  53. jasmineToString(): string;
  54. }
  55. // taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
  56. interface ArrayLike<T> {
  57. length: number;
  58. [n: number]: T;
  59. }
  60. interface ArrayContaining {
  61. new (sample: any[]): any;
  62. asymmetricMatch(other: any): boolean;
  63. jasmineToString(): string;
  64. }
  65. interface ObjectContaining {
  66. new (sample: any): any;
  67. jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
  68. jasmineToString(): string;
  69. }
  70. interface Block {
  71. new (env: Env, func: SpecFunction, spec: Spec): any;
  72. execute(onComplete: () => void): void;
  73. }
  74. interface WaitsBlock extends Block {
  75. new (env: Env, timeout: number, spec: Spec): any;
  76. }
  77. interface WaitsForBlock extends Block {
  78. new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any;
  79. }
  80. interface Clock {
  81. install(): void;
  82. uninstall(): void;
  83. /** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */
  84. tick(ms: number): void;
  85. mockDate(date?: Date): void;
  86. }
  87. interface CustomEqualityTester {
  88. (first: any, second: any): boolean;
  89. }
  90. interface CustomMatcher {
  91. compare<T>(actual: T, expected: T): CustomMatcherResult;
  92. compare(actual: any, expected: any): CustomMatcherResult;
  93. }
  94. interface CustomMatcherFactory {
  95. (util: MatchersUtil, customEqualityTesters: Array<CustomEqualityTester>): CustomMatcher;
  96. }
  97. interface CustomMatcherFactories {
  98. [index: string]: CustomMatcherFactory;
  99. }
  100. interface CustomMatcherResult {
  101. pass: boolean;
  102. message?: string;
  103. }
  104. interface MatchersUtil {
  105. equals(a: any, b: any, customTesters?: Array<CustomEqualityTester>): boolean;
  106. contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: Array<CustomEqualityTester>): boolean;
  107. buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array<any>): string;
  108. }
  109. interface Env {
  110. setTimeout: any;
  111. clearTimeout: void;
  112. setInterval: any;
  113. clearInterval: void;
  114. updateInterval: number;
  115. currentSpec: Spec;
  116. matchersClass: Matchers;
  117. version(): any;
  118. versionString(): string;
  119. nextSpecId(): number;
  120. addReporter(reporter: Reporter): void;
  121. execute(): void;
  122. describe(description: string, specDefinitions: () => void): Suite;
  123. // ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these
  124. beforeEach(beforeEachFunction: () => void): void;
  125. beforeAll(beforeAllFunction: () => void): void;
  126. currentRunner(): Runner;
  127. afterEach(afterEachFunction: () => void): void;
  128. afterAll(afterAllFunction: () => void): void;
  129. xdescribe(desc: string, specDefinitions: () => void): XSuite;
  130. it(description: string, func: () => void): Spec;
  131. // iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these
  132. xit(desc: string, func: () => void): XSpec;
  133. compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean;
  134. compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
  135. equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
  136. contains_(haystack: any, needle: any): boolean;
  137. addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
  138. addMatchers(matchers: CustomMatcherFactories): void;
  139. specFilter(spec: Spec): boolean;
  140. throwOnExpectationFailure(value: boolean): void;
  141. }
  142. interface FakeTimer {
  143. new (): any;
  144. reset(): void;
  145. tick(millis: number): void;
  146. runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
  147. scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
  148. }
  149. interface HtmlReporter {
  150. new (): any;
  151. }
  152. interface HtmlSpecFilter {
  153. new (): any;
  154. }
  155. interface Result {
  156. type: string;
  157. }
  158. interface NestedResults extends Result {
  159. description: string;
  160. totalCount: number;
  161. passedCount: number;
  162. failedCount: number;
  163. skipped: boolean;
  164. rollupCounts(result: NestedResults): void;
  165. log(values: any): void;
  166. getItems(): Result[];
  167. addResult(result: Result): void;
  168. passed(): boolean;
  169. }
  170. interface MessageResult extends Result {
  171. values: any;
  172. trace: Trace;
  173. }
  174. interface ExpectationResult extends Result {
  175. matcherName: string;
  176. passed(): boolean;
  177. expected: any;
  178. actual: any;
  179. message: string;
  180. trace: Trace;
  181. }
  182. interface Trace {
  183. name: string;
  184. message: string;
  185. stack: any;
  186. }
  187. interface PrettyPrinter {
  188. new (): any;
  189. format(value: any): void;
  190. iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void;
  191. emitScalar(value: any): void;
  192. emitString(value: string): void;
  193. emitArray(array: any[]): void;
  194. emitObject(obj: any): void;
  195. append(value: any): void;
  196. }
  197. interface StringPrettyPrinter extends PrettyPrinter {
  198. }
  199. interface Queue {
  200. new (env: any): any;
  201. env: Env;
  202. ensured: boolean[];
  203. blocks: Block[];
  204. running: boolean;
  205. index: number;
  206. offset: number;
  207. abort: boolean;
  208. addBefore(block: Block, ensure?: boolean): void;
  209. add(block: any, ensure?: boolean): void;
  210. insertNext(block: any, ensure?: boolean): void;
  211. start(onComplete?: () => void): void;
  212. isRunning(): boolean;
  213. next_(): void;
  214. results(): NestedResults;
  215. }
  216. interface Matchers {
  217. new (env: Env, actual: any, spec: Env, isNot?: boolean): any;
  218. env: Env;
  219. actual: any;
  220. spec: Env;
  221. isNot?: boolean;
  222. message(): any;
  223. toBe(expected: any, expectationFailOutput?: any): boolean;
  224. toEqual(expected: any, expectationFailOutput?: any): boolean;
  225. toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean;
  226. toBeDefined(expectationFailOutput?: any): boolean;
  227. toBeUndefined(expectationFailOutput?: any): boolean;
  228. toBeNull(expectationFailOutput?: any): boolean;
  229. toBeNaN(): boolean;
  230. toBeTruthy(expectationFailOutput?: any): boolean;
  231. toBeFalsy(expectationFailOutput?: any): boolean;
  232. toHaveBeenCalled(): boolean;
  233. toHaveBeenCalledWith(...params: any[]): boolean;
  234. toHaveBeenCalledTimes(expected: number): boolean;
  235. toContain(expected: any, expectationFailOutput?: any): boolean;
  236. toBeLessThan(expected: number, expectationFailOutput?: any): boolean;
  237. toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean;
  238. toBeCloseTo(expected: number, precision?: any, expectationFailOutput?: any): boolean;
  239. toThrow(expected?: any): boolean;
  240. toThrowError(message?: string | RegExp): boolean;
  241. toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean;
  242. not: Matchers;
  243. Any: Any;
  244. }
  245. interface Reporter {
  246. reportRunnerStarting(runner: Runner): void;
  247. reportRunnerResults(runner: Runner): void;
  248. reportSuiteResults(suite: Suite): void;
  249. reportSpecStarting(spec: Spec): void;
  250. reportSpecResults(spec: Spec): void;
  251. log(str: string): void;
  252. }
  253. interface MultiReporter extends Reporter {
  254. addReporter(reporter: Reporter): void;
  255. }
  256. interface Runner {
  257. new (env: Env): any;
  258. execute(): void;
  259. beforeEach(beforeEachFunction: SpecFunction): void;
  260. afterEach(afterEachFunction: SpecFunction): void;
  261. beforeAll(beforeAllFunction: SpecFunction): void;
  262. afterAll(afterAllFunction: SpecFunction): void;
  263. finishCallback(): void;
  264. addSuite(suite: Suite): void;
  265. add(block: Block): void;
  266. specs(): Spec[];
  267. suites(): Suite[];
  268. topLevelSuites(): Suite[];
  269. results(): NestedResults;
  270. }
  271. interface SpecFunction {
  272. (spec?: Spec): void;
  273. }
  274. interface SuiteOrSpec {
  275. id: number;
  276. env: Env;
  277. description: string;
  278. queue: Queue;
  279. }
  280. interface Spec extends SuiteOrSpec {
  281. new (env: Env, suite: Suite, description: string): any;
  282. suite: Suite;
  283. afterCallbacks: SpecFunction[];
  284. spies_: Spy[];
  285. results_: NestedResults;
  286. matchersClass: Matchers;
  287. getFullName(): string;
  288. results(): NestedResults;
  289. log(arguments: any): any;
  290. runs(func: SpecFunction): Spec;
  291. addToQueue(block: Block): void;
  292. addMatcherResult(result: Result): void;
  293. expect(actual: any): any;
  294. waits(timeout: number): Spec;
  295. waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
  296. fail(e?: any): void;
  297. getMatchersClass_(): Matchers;
  298. addMatchers(matchersPrototype: CustomMatcherFactories): void;
  299. finishCallback(): void;
  300. finish(onComplete?: () => void): void;
  301. after(doAfter: SpecFunction): void;
  302. execute(onComplete?: () => void): any;
  303. addBeforesAndAftersToQueue(): void;
  304. explodes(): void;
  305. spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
  306. removeAllSpies(): void;
  307. }
  308. interface XSpec {
  309. id: number;
  310. runs(): void;
  311. }
  312. interface Suite extends SuiteOrSpec {
  313. new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any;
  314. parentSuite: Suite;
  315. getFullName(): string;
  316. finish(onComplete?: () => void): void;
  317. beforeEach(beforeEachFunction: SpecFunction): void;
  318. afterEach(afterEachFunction: SpecFunction): void;
  319. beforeAll(beforeAllFunction: SpecFunction): void;
  320. afterAll(afterAllFunction: SpecFunction): void;
  321. results(): NestedResults;
  322. add(suiteOrSpec: SuiteOrSpec): void;
  323. specs(): Spec[];
  324. suites(): Suite[];
  325. children(): any[];
  326. execute(onComplete?: () => void): void;
  327. }
  328. interface XSuite {
  329. execute(): void;
  330. }
  331. interface Spy {
  332. (...params: any[]): any;
  333. identity: string;
  334. and: SpyAnd;
  335. calls: Calls;
  336. mostRecentCall: { args: any[]; };
  337. argsForCall: any[];
  338. wasCalled: boolean;
  339. }
  340. interface SpyAnd {
  341. /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */
  342. callThrough(): Spy;
  343. /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */
  344. returnValue(val: any): Spy;
  345. /** By chaining the spy with and.returnValues, all calls to the function will return specific values in order until it reaches the end of the return values list. */
  346. returnValues(...values: any[]): Spy;
  347. /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */
  348. callFake(fn: Function): Spy;
  349. /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */
  350. throwError(msg: string): Spy;
  351. /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */
  352. stub(): Spy;
  353. }
  354. interface Calls {
  355. /** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/
  356. any(): boolean;
  357. /** By chaining the spy with calls.count(), will return the number of times the spy was called **/
  358. count(): number;
  359. /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/
  360. argsFor(index: number): any[];
  361. /** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/
  362. allArgs(): any[];
  363. /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/
  364. all(): CallInfo[];
  365. /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/
  366. mostRecent(): CallInfo;
  367. /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/
  368. first(): CallInfo;
  369. /** By chaining the spy with calls.reset(), will clears all tracking for a spy **/
  370. reset(): void;
  371. }
  372. interface CallInfo {
  373. /** The context (the this) for the call */
  374. object: any;
  375. /** All arguments passed to the call */
  376. args: any[];
  377. /** The return value of the call */
  378. returnValue: any;
  379. }
  380. interface Util {
  381. inherit(childClass: Function, parentClass: Function): any;
  382. formatException(e: any): any;
  383. htmlEscape(str: string): string;
  384. argsToArray(args: any): any;
  385. extend(destination: any, source: any): any;
  386. }
  387. interface JsApiReporter extends Reporter {
  388. started: boolean;
  389. finished: boolean;
  390. result: any;
  391. messages: any;
  392. new (): any;
  393. suites(): Suite[];
  394. summarize_(suiteOrSpec: SuiteOrSpec): any;
  395. results(): any;
  396. resultsForSpec(specId: any): any;
  397. log(str: any): any;
  398. resultsForSpecs(specIds: any): any;
  399. summarizeResult_(result: any): any;
  400. }
  401. interface Jasmine {
  402. Spec: Spec;
  403. clock: Clock;
  404. util: Util;
  405. }
  406. export var HtmlReporter: HtmlReporter;
  407. export var HtmlSpecFilter: HtmlSpecFilter;
  408. export var DEFAULT_TIMEOUT_INTERVAL: number;
  409. }