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