Skip to content

Commit f20fb40

Browse files
committed
feat(sandbox): expose interface to create async flush scheduler
1 parent b1d55b2 commit f20fb40

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/RxAsyncSandboxInstance.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface RxAsyncSandboxInstance {}
2+
3+
export { RxAsyncSandboxInstance };

src/RxSandbox.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { SubscriptionLog } from 'rxjs/dist/types/internal/testing/SubscriptionLog';
22
import { TestMessage } from './message/TestMessage';
3+
import { RxAsyncSandboxInstance } from './RxAsyncSandboxInstance';
34
import { RxSandboxInstance } from './RxSandboxInstance';
4-
import { SandboxOption } from './SandboxOption';
5+
import { AsyncFlushSandboxOption, SandboxOption } from './SandboxOption';
56

67
export interface RxSandbox {
78
/**
@@ -11,6 +12,7 @@ export interface RxSandbox {
1112
* @return {RxSandboxInstance} instance of test scheduler interfaces.
1213
*/
1314
create(autoFlush?: boolean, frameTimeFactor?: number, maxFrameValue?: number): RxSandboxInstance;
15+
create(options: AsyncFlushSandboxOption): RxAsyncSandboxInstance;
1416
create(options?: Partial<SandboxOption>): RxSandboxInstance;
1517
/**
1618
* Utility assertion method to assert marble based observable test messages.

src/RxSandboxInstance.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type expectedObservable = <T = string>(
1414
) => Readonly<Array<TestMessage<T | Array<TestMessage<T>>>>>;
1515
type expectedSubscription = (marble: string) => SubscriptionLog;
1616

17-
type RxSandboxInstance = {
17+
interface RxSandboxInstance {
1818
/**
1919
* Test scheduler created for sandbox instance
2020
*/
@@ -49,7 +49,7 @@ type RxSandboxInstance = {
4949
* Utility function to generate `expected` subscriptions via marble diagram.
5050
*/
5151
s: expectedSubscription;
52-
};
52+
}
5353

5454
export {
5555
hotObservable,

src/SandboxOption.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,14 @@ interface SandboxOption {
1818
maxFrameValue: number;
1919
}
2020

21-
export { SandboxOption };
21+
interface AsyncFlushSandboxOption extends Partial<SandboxOption> {
22+
/**
23+
* Scheduling each actions into next available tick when flush
24+
* along with native promises chained in inner observables.
25+
*
26+
* Scheduler's flush will no longer resolve synchronously.
27+
*/
28+
flushWithAsyncTick: true;
29+
}
30+
31+
export { SandboxOption, AsyncFlushSandboxOption };

0 commit comments

Comments
 (0)