UNPKG

4.32 kBTypeScriptView Raw
1import { Observable } from '../Observable';
2import { ColdObservable } from './ColdObservable';
3import { HotObservable } from './HotObservable';
4import { TestMessage } from './TestMessage';
5import { SubscriptionLog } from './SubscriptionLog';
6import { VirtualTimeScheduler } from '../scheduler/VirtualTimeScheduler';
7export interface RunHelpers {
8 cold: typeof TestScheduler.prototype.createColdObservable;
9 hot: typeof TestScheduler.prototype.createHotObservable;
10 flush: typeof TestScheduler.prototype.flush;
11 time: typeof TestScheduler.prototype.createTime;
12 expectObservable: typeof TestScheduler.prototype.expectObservable;
13 expectSubscriptions: typeof TestScheduler.prototype.expectSubscriptions;
14 animate: (marbles: string) => void;
15}
16export declare type observableToBeFn = (marbles: string, values?: any, errorValue?: any) => void;
17export declare type subscriptionLogsToBeFn = (marbles: string | string[]) => void;
18export declare class TestScheduler extends VirtualTimeScheduler {
19 assertDeepEqual: (actual: any, expected: any) => boolean | void;
20 /**
21 * The number of virtual time units each character in a marble diagram represents. If
22 * the test scheduler is being used in "run mode", via the `run` method, this is temporarly
23 * set to `1` for the duration of the `run` block, then set back to whatever value it was.
24 * @nocollapse
25 */
26 static frameTimeFactor: number;
27 /**
28 * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.
29 */
30 readonly hotObservables: HotObservable<any>[];
31 /**
32 * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.
33 */
34 readonly coldObservables: ColdObservable<any>[];
35 /**
36 * Test meta data to be processed during `flush()`
37 */
38 private flushTests;
39 /**
40 * Indicates whether the TestScheduler instance is operating in "run mode",
41 * meaning it's processing a call to `run()`
42 */
43 private runMode;
44 /**
45 *
46 * @param assertDeepEqual A function to set up your assertion for your test harness
47 */
48 constructor(assertDeepEqual: (actual: any, expected: any) => boolean | void);
49 createTime(marbles: string): number;
50 /**
51 * @param marbles A diagram in the marble DSL. Letters map to keys in `values` if provided.
52 * @param values Values to use for the letters in `marbles`. If ommitted, the letters themselves are used.
53 * @param error The error to use for the `#` marble (if present).
54 */
55 createColdObservable<T = string>(marbles: string, values?: {
56 [marble: string]: T;
57 }, error?: any): ColdObservable<T>;
58 /**
59 * @param marbles A diagram in the marble DSL. Letters map to keys in `values` if provided.
60 * @param values Values to use for the letters in `marbles`. If ommitted, the letters themselves are used.
61 * @param error The error to use for the `#` marble (if present).
62 */
63 createHotObservable<T = string>(marbles: string, values?: {
64 [marble: string]: T;
65 }, error?: any): HotObservable<T>;
66 private materializeInnerObservable;
67 expectObservable<T>(observable: Observable<T>, subscriptionMarbles?: string | null): {
68 toBe(marbles: string, values?: any, errorValue?: any): void;
69 toEqual: (other: Observable<T>) => void;
70 };
71 expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): {
72 toBe: subscriptionLogsToBeFn;
73 };
74 flush(): void;
75 /** @nocollapse */
76 static parseMarblesAsSubscriptions(marbles: string | null, runMode?: boolean): SubscriptionLog;
77 /** @nocollapse */
78 static parseMarbles(marbles: string, values?: any, errorValue?: any, materializeInnerObservables?: boolean, runMode?: boolean): TestMessage[];
79 private createAnimator;
80 private createDelegates;
81 /**
82 * The `run` method performs the test in 'run mode' - in which schedulers
83 * used within the test automatically delegate to the `TestScheduler`. That
84 * is, in 'run mode' there is no need to explicitly pass a `TestScheduler`
85 * instance to observable creators or operators.
86 *
87 * @see {@link /guide/testing/marble-testing}
88 */
89 run<T>(callback: (helpers: RunHelpers) => T): T;
90}
91//# sourceMappingURL=TestScheduler.d.ts.map
\No newline at end of file