1b9f3215c91b5778ce086c703a6b51744ea8ac667ba5db54a06ef888a72c491225ce55e5bc0ea49b30b334402ab1d3cc7aef4144c52defeebdbfbcb449aa38 4.2 KB

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