@ngxs/store
Version:
75 lines (68 loc) • 2.59 kB
TypeScript
import { NgxsModuleOptions, Store } from '@ngxs/store';
import * as i0 from '@angular/core';
import { EnvironmentProviders, ModuleWithProviders } from '@angular/core';
import { TestBedStatic } from '@angular/core/testing';
import { ɵStateClass as _StateClass } from '@ngxs/store/internals';
declare function freshPlatform(fn: (done?: VoidFunction) => Promise<void>): () => Promise<void>;
interface NgxsOptionsTesting {
states?: _StateClass[];
ngxsOptions?: NgxsModuleOptions;
imports?: ModuleWithProviders<any>[];
before?: () => void;
}
interface NgxsTesting {
store: Store;
getTestBed: TestBedStatic;
}
declare class NgxsTestBed {
static configureTestingStates(options: NgxsOptionsTesting): NgxsTesting;
private static ngxsBootstrap;
private static resetTestBed;
private static createRootNode;
}
type ConsoleRecord = [string, any[]];
type ConsoleRecorder = ConsoleRecord[];
declare function loggedError(message: string): ConsoleRecord;
declare function skipConsoleLogging<T extends (...args: any[]) => any>(fn: T, consoleRecorder?: ConsoleRecorder): ReturnType<T>;
declare class NgxsActionCollector {
/**
* Including this in your providers will
* set up the the action collector to start collecting actions
* from before NGXS initializes
* @example
* // In your providers declaration for your tests:
* {
* providers: [
* NgxsActionCollector.collectActions(),
* provideStore([MyState]),
* ],
* // ...
* }
* // and then in your test:
* const actionCollector = TestBed.inject(NgxsActionCollector);
* const actionsDispatched = actionCollector.dispatched;
* const action = actionsDispatched.find(
* (item) => item instanceof MyAction
* );
* expect(action).toBeDefined();
* @returns An environment initializer that starts the collector immediately
*/
static collectActions(): EnvironmentProviders;
private _destroyed$;
private _stopped$;
private _started;
readonly dispatched: any[];
readonly completed: any[];
readonly successful: any[];
readonly errored: any[];
readonly cancelled: any[];
private _actions$;
constructor();
start(): void;
reset(): void;
stop(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxsActionCollector, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NgxsActionCollector>;
}
export { NgxsActionCollector, NgxsTestBed, freshPlatform, loggedError, skipConsoleLogging };
export type { ConsoleRecord, ConsoleRecorder, NgxsTesting };