1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | type ImplementationCallback = jasmine.ImplementationCallback;
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | declare function describe(description: string, specDefinitions: () => void): void;
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | declare function fdescribe(description: string, specDefinitions: () => void): void;
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | declare function xdescribe(description: string, specDefinitions: () => void): void;
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | declare function it(expectation: string, assertion?: jasmine.ImplementationCallback, timeout?: number): void;
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | declare function fit(expectation: string, assertion?: jasmine.ImplementationCallback, timeout?: number): void;
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | declare function xit(expectation: string, assertion?: jasmine.ImplementationCallback, timeout?: number): void;
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | declare function pending(reason?: string): void;
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | declare function beforeEach(action: jasmine.ImplementationCallback, timeout?: number): void;
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | declare function afterEach(action: jasmine.ImplementationCallback, timeout?: number): void;
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | declare function beforeAll(action: jasmine.ImplementationCallback, timeout?: number): void;
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | declare function afterAll(action: jasmine.ImplementationCallback, timeout?: number): void;
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | declare function expect(spy: Function): jasmine.Matchers<any>;
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | declare function expect<T>(actual: ArrayLike<T>): jasmine.ArrayLikeMatchers<T>;
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | declare function expect<T>(actual: T): jasmine.Matchers<T>;
|
130 |
|
131 |
|
132 |
|
133 |
|
134 | declare function expect(): jasmine.NothingMatcher;
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | declare function expectAsync<T, U>(actual: PromiseLike<T>): jasmine.AsyncMatchers<T, U>;
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | declare function fail(e?: any): void;
|
151 |
|
152 |
|
153 |
|
154 |
|
155 | interface DoneFn extends Function {
|
156 | (): void;
|
157 |
|
158 |
|
159 | fail: (message?: Error | string) => void;
|
160 | }
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 | declare function spyOn<T>(object: T, method: keyof T): jasmine.Spy;
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 | declare function spyOnProperty<T>(object: T, property: keyof T, accessType?: 'get' | 'set'): jasmine.Spy;
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 | declare function spyOnAllFunctions<T>(object: T): jasmine.SpyObj<T>;
|
182 |
|
183 | declare function runs(asyncMethod: Function): void;
|
184 | declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void;
|
185 | declare function waits(timeout?: number): void;
|
186 |
|
187 | declare namespace jasmine {
|
188 | type Func = (...args: any[]) => any;
|
189 |
|
190 |
|
191 |
|
192 | type Constructor = Function & { prototype: any };
|
193 |
|
194 | type ImplementationCallback = (() => PromiseLike<any>) | ((done: DoneFn) => void);
|
195 |
|
196 | type ExpectedRecursive<T> = T | ObjectContaining<T> | AsymmetricMatcher<any> | {
|
197 | [K in keyof T]: ExpectedRecursive<T[K]> | Any;
|
198 | };
|
199 | type Expected<T> = T | ObjectContaining<T> | AsymmetricMatcher<any> | Any | Spy | {
|
200 | [K in keyof T]: ExpectedRecursive<T[K]>;
|
201 | };
|
202 | type SpyObjMethodNames<T = undefined> =
|
203 | T extends undefined ?
|
204 | (ReadonlyArray<string> | { [methodName: string]: any }) :
|
205 | (ReadonlyArray<keyof T> | { [P in keyof T]?: T[P] extends Func ? ReturnType<T[P]> : any });
|
206 |
|
207 | type SpyObjPropertyNames<T = undefined> =
|
208 | T extends undefined ?
|
209 | (ReadonlyArray<string> | { [propertyName: string]: any }) :
|
210 | (ReadonlyArray<keyof T>);
|
211 |
|
212 | /**
|
213 | * Configuration that can be used when configuring Jasmine via {@link jasmine.Env.configure}
|
214 | */
|
215 | interface EnvConfiguration {
|
216 | random?: boolean;
|
217 | seed?: number;
|
218 | failFast?: boolean;
|
219 | failSpecWithNoExpectations?: boolean;
|
220 | oneFailurePerSpec?: boolean;
|
221 | hideDisabled?: boolean;
|
222 | specFilter?: Function;
|
223 | Promise?: Function;
|
224 | }
|
225 |
|
226 | function clock(): Clock;
|
227 |
|
228 | var matchersUtil: MatchersUtil;
|
229 |
|
230 | /**
|
231 | * That will succeed if the actual value being compared is an instance of the specified class/constructor.
|
232 | */
|
233 | function any(aclass: Constructor | Symbol): AsymmetricMatcher<any>;
|
234 |
|
235 | /**
|
236 | * That will succeed if the actual value being compared is not `null` and not `undefined`.
|
237 | */
|
238 | function anything(): AsymmetricMatcher<any>;
|
239 |
|
240 | /**
|
241 | * That will succeed if the actual value being compared is `true` or anything truthy.
|
242 | * @since 3.1.0
|
243 | */
|
244 | function truthy(): AsymmetricMatcher<any>;
|
245 |
|
246 | /**
|
247 | * That will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
|
248 | * @since 3.1.0
|
249 | */
|
250 | function falsy(): AsymmetricMatcher<any>;
|
251 |
|
252 | /**
|
253 | * That will succeed if the actual value being compared is empty.
|
254 | * @since 3.1.0
|
255 | */
|
256 | function empty(): AsymmetricMatcher<any>;
|
257 |
|
258 | /**
|
259 | * That will succeed if the actual value being compared is not empty.
|
260 | * @since 3.1.0
|
261 | */
|
262 | function notEmpty(): AsymmetricMatcher<any>;
|
263 |
|
264 | function arrayContaining<T>(sample: ArrayLike<T>): ArrayContaining<T>;
|
265 | function arrayWithExactContents<T>(sample: ArrayLike<T>): ArrayContaining<T>;
|
266 | function objectContaining<T>(sample: {[K in keyof T]?: ExpectedRecursive<T[K]>}): ObjectContaining<T>;
|
267 |
|
268 | function setDefaultSpyStrategy(and: SpyAnd): void;
|
269 | function createSpy(name?: string, originalFn?: Function): Spy;
|
270 | function createSpyObj(baseName: string, methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): any;
|
271 | function createSpyObj<T>(baseName: string, methodNames: SpyObjMethodNames<T>, propertyNames?: SpyObjPropertyNames<T>): SpyObj<T>;
|
272 | function createSpyObj(methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): any;
|
273 | function createSpyObj<T>(methodNames: SpyObjMethodNames<T>, propertyNames?: SpyObjPropertyNames<T>): SpyObj<T>;
|
274 |
|
275 | function pp(value: any): string;
|
276 |
|
277 | function getEnv(): Env;
|
278 |
|
279 | function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
280 |
|
281 | function addMatchers(matchers: CustomMatcherFactories): void;
|
282 | function addAsyncMatchers(matchers: CustomMatcherFactories): void;
|
283 |
|
284 | function stringMatching(str: string | RegExp): AsymmetricMatcher<string>;
|
285 |
|
286 | function formatErrorMsg(domain: string, usage: string): (msg: string) => string;
|
287 |
|
288 | interface Any extends AsymmetricMatcher<any> {
|
289 | (...params: any[]): any;
|
290 | new (expectedClass: any): any;
|
291 |
|
292 | jasmineMatches(other: any): boolean;
|
293 | jasmineToString(): string;
|
294 | }
|
295 |
|
296 | interface AsymmetricMatcher<TValue> {
|
297 | asymmetricMatch(other: TValue, customTesters: ReadonlyArray<CustomEqualityTester>): boolean;
|
298 | jasmineToString?(): string;
|
299 | }
|
300 |
|
301 |
|
302 | interface ArrayLike<T> {
|
303 | length: number;
|
304 | [n: number]: T;
|
305 | }
|
306 |
|
307 | interface ArrayContaining<T> extends AsymmetricMatcher<any> {
|
308 | new?(sample: ArrayLike<T>): ArrayLike<T>;
|
309 | }
|
310 |
|
311 | interface ObjectContaining<T> extends AsymmetricMatcher<any> {
|
312 | new?(sample: {[K in keyof T]?: any}): {[K in keyof T]?: any};
|
313 |
|
314 | jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
|
315 | jasmineToString?(): string;
|
316 | }
|
317 |
|
318 | interface Block {
|
319 | new (env: Env, func: SpecFunction, spec: Spec): any;
|
320 |
|
321 | execute(onComplete: () => void): void;
|
322 | }
|
323 |
|
324 | interface WaitsBlock extends Block {
|
325 | new (env: Env, timeout: number, spec: Spec): any;
|
326 | }
|
327 |
|
328 | interface WaitsForBlock extends Block {
|
329 | new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any;
|
330 | }
|
331 |
|
332 | interface Clock {
|
333 | install(): void;
|
334 | uninstall(): void;
|
335 |
|
336 | tick(ms: number): void;
|
337 | mockDate(date?: Date): void;
|
338 | withMock(func: () => void): void;
|
339 | }
|
340 |
|
341 | type CustomEqualityTester = (first: any, second: any) => boolean | void;
|
342 |
|
343 | interface CustomMatcher {
|
344 | compare<T>(actual: T, expected: T, ...args: any[]): CustomMatcherResult;
|
345 | compare(actual: any, ...expected: any[]): CustomMatcherResult;
|
346 | negativeCompare?<T>(actual: T, expected: T, ...args: any[]): CustomMatcherResult;
|
347 | negativeCompare?(actual: any, ...expected: any[]): CustomMatcherResult;
|
348 | }
|
349 |
|
350 | type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: ReadonlyArray<CustomEqualityTester>) => CustomMatcher;
|
351 |
|
352 | interface CustomMatcherFactories {
|
353 | [index: string]: CustomMatcherFactory;
|
354 | }
|
355 |
|
356 | interface CustomMatcherResult {
|
357 | pass: boolean;
|
358 | message?: string;
|
359 | }
|
360 |
|
361 | interface MatchersUtil {
|
362 | equals(a: any, b: any, customTesters?: ReadonlyArray<CustomEqualityTester>): boolean;
|
363 | contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: ReadonlyArray<CustomEqualityTester>): boolean;
|
364 | buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string;
|
365 | }
|
366 |
|
367 | interface Env {
|
368 | currentSpec: Spec;
|
369 |
|
370 | matchersClass: Matchers<any>;
|
371 |
|
372 | version(): any;
|
373 | versionString(): string;
|
374 | nextSpecId(): number;
|
375 | addReporter(reporter: Reporter | CustomReporter): void;
|
376 | execute(): void;
|
377 | describe(description: string, specDefinitions: () => void): Suite;
|
378 |
|
379 | beforeEach(beforeEachFunction: ImplementationCallback, timeout?: number): void;
|
380 | beforeAll(beforeAllFunction: ImplementationCallback, timeout?: number): void;
|
381 | currentRunner(): Runner;
|
382 | afterEach(afterEachFunction: ImplementationCallback, timeout?: number): void;
|
383 | afterAll(afterAllFunction: ImplementationCallback, timeout?: number): void;
|
384 | xdescribe(desc: string, specDefinitions: () => void): XSuite;
|
385 | it(description: string, func: () => void): Spec;
|
386 |
|
387 | xit(desc: string, func: () => void): XSpec;
|
388 | compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
389 | compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
390 | equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
391 | contains_(haystack: any, needle: any): boolean;
|
392 | addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
393 | addMatchers(matchers: CustomMatcherFactories): void;
|
394 | specFilter(spec: Spec): boolean;
|
395 | |
396 |
|
397 |
|
398 | throwOnExpectationFailure(value: boolean): void;
|
399 | |
400 |
|
401 |
|
402 | stopOnSpecFailure(value: boolean): void;
|
403 | |
404 |
|
405 |
|
406 | seed(seed: string | number): string | number;
|
407 | provideFallbackReporter(reporter: Reporter): void;
|
408 | throwingExpectationFailures(): boolean;
|
409 | allowRespy(allow: boolean): void;
|
410 | randomTests(): boolean;
|
411 | |
412 |
|
413 |
|
414 | randomizeTests(b: boolean): void;
|
415 | clearReporters(): void;
|
416 | configure(configuration: EnvConfiguration): void;
|
417 | }
|
418 |
|
419 | interface FakeTimer {
|
420 | new (): any;
|
421 |
|
422 | reset(): void;
|
423 | tick(millis: number): void;
|
424 | runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
|
425 | scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
|
426 | }
|
427 |
|
428 | interface HtmlReporter {
|
429 | new (): any;
|
430 | }
|
431 |
|
432 | interface HtmlSpecFilter {
|
433 | new (): any;
|
434 | }
|
435 |
|
436 | interface Result {
|
437 | type: string;
|
438 | }
|
439 |
|
440 | interface NestedResults extends Result {
|
441 | description: string;
|
442 |
|
443 | totalCount: number;
|
444 | passedCount: number;
|
445 | failedCount: number;
|
446 |
|
447 | skipped: boolean;
|
448 |
|
449 | rollupCounts(result: NestedResults): void;
|
450 | log(values: any): void;
|
451 | getItems(): Result[];
|
452 | addResult(result: Result): void;
|
453 | passed(): boolean;
|
454 | }
|
455 |
|
456 | interface MessageResult extends Result {
|
457 | values: any;
|
458 | trace: Trace;
|
459 | }
|
460 |
|
461 | interface ExpectationResult extends Result {
|
462 | matcherName: string;
|
463 | passed(): boolean;
|
464 | expected: any;
|
465 | actual: any;
|
466 | message: string;
|
467 | trace: Trace;
|
468 | }
|
469 |
|
470 | interface Order {
|
471 | new (options: { random: boolean, seed: string }): any;
|
472 | random: boolean;
|
473 | seed: string;
|
474 | sort<T>(items: T[]): T[];
|
475 | }
|
476 |
|
477 | namespace errors {
|
478 | class ExpectationFailed extends Error {
|
479 | constructor();
|
480 |
|
481 | stack: any;
|
482 | }
|
483 | }
|
484 |
|
485 | interface TreeProcessor {
|
486 | new (attrs: any): any;
|
487 | execute: (done: Function) => void;
|
488 | processTree(): any;
|
489 | }
|
490 |
|
491 | interface Trace {
|
492 | name: string;
|
493 | message: string;
|
494 | stack: any;
|
495 | }
|
496 |
|
497 | interface PrettyPrinter {
|
498 | new (): any;
|
499 |
|
500 | format(value: any): void;
|
501 | iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void;
|
502 | emitScalar(value: any): void;
|
503 | emitString(value: string): void;
|
504 | emitArray(array: any[]): void;
|
505 | emitObject(obj: any): void;
|
506 | append(value: any): void;
|
507 | }
|
508 |
|
509 | interface StringPrettyPrinter extends PrettyPrinter {
|
510 | }
|
511 |
|
512 | interface Queue {
|
513 | new (env: any): any;
|
514 |
|
515 | env: Env;
|
516 | ensured: boolean[];
|
517 | blocks: Block[];
|
518 | running: boolean;
|
519 | index: number;
|
520 | offset: number;
|
521 | abort: boolean;
|
522 |
|
523 | addBefore(block: Block, ensure?: boolean): void;
|
524 | add(block: any, ensure?: boolean): void;
|
525 | insertNext(block: any, ensure?: boolean): void;
|
526 | start(onComplete?: () => void): void;
|
527 | isRunning(): boolean;
|
528 | next_(): void;
|
529 | results(): NestedResults;
|
530 | }
|
531 |
|
532 | interface Matchers<T> {
|
533 | new (env: Env, actual: T, spec: Env, isNot?: boolean): any;
|
534 |
|
535 | env: Env;
|
536 | actual: T;
|
537 | spec: Env;
|
538 | isNot?: boolean;
|
539 | message(): any;
|
540 |
|
541 | |
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 | toBe(expected: Expected<T>, expectationFailOutput?: any): boolean;
|
550 |
|
551 | |
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 | toEqual(expected: Expected<T>, expectationFailOutput?: any): boolean;
|
559 |
|
560 | |
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 | toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean;
|
568 |
|
569 | toBeDefined(expectationFailOutput?: any): boolean;
|
570 | toBeUndefined(expectationFailOutput?: any): boolean;
|
571 | toBeNull(expectationFailOutput?: any): boolean;
|
572 | toBeNaN(): boolean;
|
573 | toBeTruthy(expectationFailOutput?: any): boolean;
|
574 | toBeFalsy(expectationFailOutput?: any): boolean;
|
575 | toBeTrue(): boolean;
|
576 | toBeFalse(): boolean;
|
577 | toHaveBeenCalled(): boolean;
|
578 | toHaveBeenCalledBefore(expected: Spy): boolean;
|
579 | toHaveBeenCalledWith(...params: any[]): boolean;
|
580 | toHaveBeenCalledTimes(expected: number): boolean;
|
581 | toContain(expected: any, expectationFailOutput?: any): boolean;
|
582 | toBeLessThan(expected: number, expectationFailOutput?: any): boolean;
|
583 | toBeLessThanOrEqual(expected: number, expectationFailOutput?: any): boolean;
|
584 | toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean;
|
585 | toBeGreaterThanOrEqual(expected: number, expectationFailOutput?: any): boolean;
|
586 | toBeCloseTo(expected: number, precision?: any, expectationFailOutput?: any): boolean;
|
587 | toThrow(expected?: any): boolean;
|
588 | toThrowError(message?: string | RegExp): boolean;
|
589 | toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean;
|
590 | toThrowMatching(predicate: (thrown: any) => boolean): boolean;
|
591 | toBeNegativeInfinity(expectationFailOutput?: any): boolean;
|
592 | toBePositiveInfinity(expectationFailOutput?: any): boolean;
|
593 | toBeInstanceOf(expected: Constructor): boolean;
|
594 |
|
595 | |
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 | toHaveClass(expected: string, expectationFailOutput?: any): boolean;
|
605 |
|
606 | |
607 |
|
608 |
|
609 |
|
610 | withContext(message: string): Matchers<T>;
|
611 |
|
612 | |
613 |
|
614 |
|
615 | not: Matchers<T>;
|
616 | }
|
617 |
|
618 | interface ArrayLikeMatchers<T> extends Matchers<ArrayLike<T>> {
|
619 | |
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 | toBe(expected: Expected<ArrayLike<T>> | ArrayContaining<T>, expectationFailOutput?: any): boolean;
|
628 |
|
629 | |
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 | toEqual(expected: Expected<ArrayLike<T>> | ArrayContaining<T>, expectationFailOutput?: any): boolean;
|
637 |
|
638 | toContain(expected: Expected<T>, expectationFailOutput?: any): boolean;
|
639 |
|
640 | |
641 |
|
642 |
|
643 |
|
644 | withContext(message: string): ArrayLikeMatchers<T>;
|
645 |
|
646 | |
647 |
|
648 |
|
649 | not: ArrayLikeMatchers<T>;
|
650 | }
|
651 |
|
652 | interface NothingMatcher {
|
653 | nothing(): void;
|
654 | }
|
655 |
|
656 | interface AsyncMatchers<T, U> {
|
657 | |
658 |
|
659 |
|
660 |
|
661 | toBeResolved(expectationFailOutput?: any): PromiseLike<void>;
|
662 |
|
663 | |
664 |
|
665 |
|
666 |
|
667 | toBeRejected(expectationFailOutput?: any): PromiseLike<void>;
|
668 |
|
669 | |
670 |
|
671 |
|
672 |
|
673 | toBeResolvedTo(expected: Expected<T>): PromiseLike<void>;
|
674 |
|
675 | |
676 |
|
677 |
|
678 |
|
679 | toBeRejectedWith(expected: Expected<U>): PromiseLike<void>;
|
680 |
|
681 | |
682 |
|
683 |
|
684 |
|
685 |
|
686 | toBeRejectedWithError(expected?: new (...args: any[]) => Error, message?: string | RegExp): PromiseLike<void>;
|
687 |
|
688 | |
689 |
|
690 |
|
691 |
|
692 | toBeRejectedWithError(message?: string | RegExp): PromiseLike<void>;
|
693 |
|
694 | |
695 |
|
696 |
|
697 |
|
698 | withContext(message: string): AsyncMatchers<T, U>;
|
699 |
|
700 | |
701 |
|
702 |
|
703 | not: AsyncMatchers<T, U>;
|
704 | }
|
705 |
|
706 | interface Reporter {
|
707 | reportRunnerStarting(runner: Runner): void;
|
708 | reportRunnerResults(runner: Runner): void;
|
709 | reportSuiteResults(suite: Suite): void;
|
710 | reportSpecStarting(spec: Spec): void;
|
711 | reportSpecResults(spec: Spec): void;
|
712 | log(str: string): void;
|
713 | }
|
714 |
|
715 | interface MultiReporter extends Reporter {
|
716 | addReporter(reporter: Reporter): void;
|
717 | }
|
718 |
|
719 | interface SuiteInfo {
|
720 | totalSpecsDefined: number;
|
721 | }
|
722 |
|
723 | interface CustomReportExpectation {
|
724 | matcherName: string;
|
725 | message: string;
|
726 | passed: boolean;
|
727 | stack: string;
|
728 | }
|
729 |
|
730 | interface FailedExpectation extends CustomReportExpectation {
|
731 | actual: string;
|
732 | expected: string;
|
733 | }
|
734 |
|
735 | interface PassedExpectation extends CustomReportExpectation {
|
736 | }
|
737 |
|
738 | interface CustomReporterResult {
|
739 | description: string;
|
740 | failedExpectations?: FailedExpectation[];
|
741 | fullName: string;
|
742 | id: string;
|
743 | passedExpectations?: PassedExpectation[];
|
744 | pendingReason?: string;
|
745 | status?: string;
|
746 | }
|
747 |
|
748 | interface RunDetails {
|
749 | failedExpectations: ExpectationResult[];
|
750 | order: Order;
|
751 | }
|
752 |
|
753 | interface CustomReporter {
|
754 | jasmineStarted?(suiteInfo: SuiteInfo): void;
|
755 | suiteStarted?(result: CustomReporterResult): void;
|
756 | specStarted?(result: CustomReporterResult): void;
|
757 | specDone?(result: CustomReporterResult): void;
|
758 | suiteDone?(result: CustomReporterResult): void;
|
759 | jasmineDone?(runDetails: RunDetails): void;
|
760 | }
|
761 |
|
762 | interface Runner {
|
763 | new (env: Env): any;
|
764 |
|
765 | execute(): void;
|
766 | beforeEach(beforeEachFunction: SpecFunction): void;
|
767 | afterEach(afterEachFunction: SpecFunction): void;
|
768 | beforeAll(beforeAllFunction: SpecFunction): void;
|
769 | afterAll(afterAllFunction: SpecFunction): void;
|
770 | finishCallback(): void;
|
771 | addSuite(suite: Suite): void;
|
772 | add(block: Block): void;
|
773 | specs(): Spec[];
|
774 | suites(): Suite[];
|
775 | topLevelSuites(): Suite[];
|
776 | results(): NestedResults;
|
777 | }
|
778 |
|
779 | type SpecFunction = (spec?: Spec) => void;
|
780 |
|
781 | interface SuiteOrSpec {
|
782 | id: number;
|
783 | env: Env;
|
784 | description: string;
|
785 | queue: Queue;
|
786 | }
|
787 |
|
788 | interface Spec extends SuiteOrSpec {
|
789 | new (env: Env, suite: Suite, description: string): any;
|
790 |
|
791 | suite: Suite;
|
792 |
|
793 | afterCallbacks: SpecFunction[];
|
794 | spies_: Spy[];
|
795 |
|
796 | results_: NestedResults;
|
797 | matchersClass: Matchers<any>;
|
798 |
|
799 | getFullName(): string;
|
800 | results(): NestedResults;
|
801 | log(arguments: any): any;
|
802 | runs(func: SpecFunction): Spec;
|
803 | addToQueue(block: Block): void;
|
804 | addMatcherResult(result: Result): void;
|
805 | getResult(): any;
|
806 | expect(actual: any): any;
|
807 | waits(timeout: number): Spec;
|
808 | waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
|
809 | fail(e?: any): void;
|
810 | getMatchersClass_(): Matchers<any>;
|
811 | addMatchers(matchersPrototype: CustomMatcherFactories): void;
|
812 | finishCallback(): void;
|
813 | finish(onComplete?: () => void): void;
|
814 | after(doAfter: SpecFunction): void;
|
815 | execute(onComplete?: () => void, enabled?: boolean): any;
|
816 | addBeforesAndAftersToQueue(): void;
|
817 | explodes(): void;
|
818 | spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
|
819 | spyOnProperty(object: any, property: string, accessType?: 'get' | 'set'): Spy;
|
820 | spyOnAllFunctions(object: any): Spy;
|
821 |
|
822 | removeAllSpies(): void;
|
823 | throwOnExpectationFailure: boolean;
|
824 | }
|
825 |
|
826 | interface XSpec {
|
827 | id: number;
|
828 | runs(): void;
|
829 | }
|
830 |
|
831 | interface Suite extends SuiteOrSpec {
|
832 | new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any;
|
833 |
|
834 | parentSuite: Suite;
|
835 |
|
836 | getFullName(): string;
|
837 | finish(onComplete?: () => void): void;
|
838 | beforeEach(beforeEachFunction: SpecFunction): void;
|
839 | afterEach(afterEachFunction: SpecFunction): void;
|
840 | beforeAll(beforeAllFunction: SpecFunction): void;
|
841 | afterAll(afterAllFunction: SpecFunction): void;
|
842 | results(): NestedResults;
|
843 | add(suiteOrSpec: SuiteOrSpec): void;
|
844 | specs(): Spec[];
|
845 | suites(): Suite[];
|
846 | children(): any[];
|
847 | execute(onComplete?: () => void): void;
|
848 | }
|
849 |
|
850 | interface XSuite {
|
851 | execute(): void;
|
852 | }
|
853 |
|
854 | interface Spy {
|
855 | (...params: any[]): any;
|
856 |
|
857 | and: SpyAnd;
|
858 | calls: Calls;
|
859 | withArgs(...args: any[]): Spy;
|
860 | }
|
861 |
|
862 | type SpyObj<T> = T & {
|
863 | [K in keyof T]: T[K] extends Function ? T[K] & Spy : T[K];
|
864 | };
|
865 |
|
866 | interface SpyAnd {
|
867 | identity: string;
|
868 |
|
869 |
|
870 | callThrough(): Spy;
|
871 |
|
872 | returnValue(val: any): Spy;
|
873 |
|
874 | returnValues(...values: any[]): Spy;
|
875 |
|
876 | callFake(fn: Function): Spy;
|
877 |
|
878 | throwError(msg: string|Error): Spy;
|
879 |
|
880 | stub(): Spy;
|
881 | }
|
882 |
|
883 | interface Calls {
|
884 |
|
885 | any(): boolean;
|
886 |
|
887 | count(): number;
|
888 |
|
889 | argsFor(index: number): any[];
|
890 |
|
891 | allArgs(): any[];
|
892 |
|
893 | all(): CallInfo[];
|
894 |
|
895 | mostRecent(): CallInfo;
|
896 |
|
897 | first(): CallInfo;
|
898 |
|
899 | reset(): void;
|
900 | }
|
901 |
|
902 | interface CallInfo {
|
903 |
|
904 | object: any;
|
905 |
|
906 | args: any[];
|
907 |
|
908 | returnValue: any;
|
909 | }
|
910 |
|
911 | interface Util {
|
912 | inherit(childClass: Function, parentClass: Function): any;
|
913 | formatException(e: any): any;
|
914 | htmlEscape(str: string): string;
|
915 | argsToArray(args: any): any;
|
916 | extend(destination: any, source: any): any;
|
917 | }
|
918 |
|
919 | interface JsApiReporter extends Reporter {
|
920 | started: boolean;
|
921 | finished: boolean;
|
922 | result: any;
|
923 | messages: any;
|
924 | runDetails: RunDetails;
|
925 |
|
926 | new (): any;
|
927 |
|
928 | suites(): Suite[];
|
929 | summarize_(suiteOrSpec: SuiteOrSpec): any;
|
930 | results(): any;
|
931 | resultsForSpec(specId: any): any;
|
932 | log(str: any): any;
|
933 | resultsForSpecs(specIds: any): any;
|
934 | summarizeResult_(result: any): any;
|
935 | }
|
936 |
|
937 | interface Jasmine {
|
938 | Spec: Spec;
|
939 | clock: Clock;
|
940 | util: Util;
|
941 | }
|
942 |
|
943 | var HtmlReporter: HtmlReporter;
|
944 | var HtmlSpecFilter: HtmlSpecFilter;
|
945 |
|
946 | |
947 |
|
948 |
|
949 | var DEFAULT_TIMEOUT_INTERVAL: number;
|
950 |
|
951 | |
952 |
|
953 |
|
954 |
|
955 |
|
956 | var MAX_PRETTY_PRINT_ARRAY_LENGTH: number;
|
957 |
|
958 | |
959 |
|
960 |
|
961 |
|
962 | var MAX_PRETTY_PRINT_CHARS: number;
|
963 |
|
964 | |
965 |
|
966 |
|
967 |
|
968 | var MAX_PRETTY_PRINT_DEPTH: number;
|
969 | }
|
970 |
|
971 | declare module "jasmine" {
|
972 | class jasmine {
|
973 | constructor(options: any);
|
974 | jasmine: jasmine.Jasmine;
|
975 | addMatchers(matchers: jasmine.CustomMatcherFactories): void;
|
976 | addReporter(reporter: jasmine.Reporter): void;
|
977 | addSpecFile(filePath: string): void;
|
978 | addSpecFiles(files: string[]): void;
|
979 | configureDefaultReporter(options: any, ...args: any[]): void;
|
980 | execute(files?: string[], filterString?: string): any;
|
981 | exitCodeCompletion(passed: any): void;
|
982 | loadConfig(config: any): void;
|
983 | loadConfigFile(configFilePath: any): void;
|
984 | loadHelpers(): void;
|
985 | loadSpecs(): void;
|
986 | onComplete(onCompleteCallback: (passed: boolean) => void): void;
|
987 | provideFallbackReporter(reporter: jasmine.Reporter): void;
|
988 | randomizeTests(value?: any): boolean;
|
989 | seed(value: any): void;
|
990 | showColors(value: any): void;
|
991 | stopSpecOnExpectationFailure(value: any): void;
|
992 | static ConsoleReporter(): any;
|
993 | env: jasmine.Env;
|
994 | reportersCount: number;
|
995 | completionReporter: jasmine.CustomReporter;
|
996 | reporter: jasmine.CustomReporter;
|
997 | coreVersion(): string;
|
998 | showingColors: boolean;
|
999 | projectBaseDir: string;
|
1000 | printDeprecation(): void;
|
1001 | specFiles: string[];
|
1002 | helperFiles: string[];
|
1003 | }
|
1004 | export = jasmine;
|
1005 | }
|