@rxx/testing
Version:
Testing module for rxx.
35 lines (34 loc) • 1.31 kB
TypeScript
import { IntentConstructor, StoreConstructor, Store, StateHandler, StateFactory } from '@rxx/core';
import { Observable, Subscription } from 'rxjs';
import { MockManipulator } from './mocker';
export declare type Prepared<V, I = IntentConstructor> = {
stores: Store<V>[];
store: Store<V>;
mock: I extends IntentConstructor ? MockManipulator : {
[P in keyof I]: MockManipulator;
};
};
export declare type PrepareOptions = {
services?: {
[key: string]: any;
};
handlers?: {
[key: string]: StateHandler;
};
state?: any;
multiIntent?: boolean;
};
export declare function prepareTest<T extends IntentConstructor | {
[key: string]: IntentConstructor;
}, U extends StoreConstructor<T, V>, V>(IntentClass: T, StoreClass: StoreConstructor<T, V> | StoreConstructor<T, V>[], opt?: PrepareOptions): Prepared<V, T>;
interface AppTesterOption {
states: {
[key: string]: any;
};
}
export declare function initAppTester<S, I>(app: StateFactory<S, I>, initialState: I, opt?: AppTesterOption): {
input(type: string, payload?: any): void;
output: S;
};
export declare function safeSubscribe<S>(observable: Observable<S>, callback: (v: S) => Promise<any>, done: (...args: any[]) => void, subscription?: Subscription): Subscription;
export {};