-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathutils.ts
More file actions
executable file
·43 lines (38 loc) · 1.24 KB
/
utils.ts
File metadata and controls
executable file
·43 lines (38 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { NgModule, Injectable } from '@angular/core';
import { SharedModule } from '@app/shared';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateModule } from '@ngx-translate/core';
import { Store, StateObservable, ActionsSubject, ReducerManager, StoreModule } from '@ngrx/store';
import { BehaviorSubject } from 'rxjs';
import { RouterTestingModule } from '@angular/router/testing';
@Injectable()
export class MockStore<T> extends Store<T> {
private stateSubject = new BehaviorSubject<T>({} as T);
constructor(state$: StateObservable, actionsObserver: ActionsSubject, reducerManager: ReducerManager) {
super(state$, actionsObserver, reducerManager);
this.source = this.stateSubject.asObservable();
}
setState(nextState: T) {
this.stateSubject.next(nextState);
}
}
export function provideMockStore() {
return {
provide: Store,
useClass: MockStore
};
}
@NgModule({
imports: [
NoopAnimationsModule,
RouterTestingModule,
SharedModule,
TranslateModule.forRoot(),
StoreModule.forRoot({})
],
exports: [NoopAnimationsModule, RouterTestingModule, SharedModule, TranslateModule],
providers: [provideMockStore()]
})
export class TestingModule {
constructor() {}
}