我最近升级了我的角应用程序的角包,包括升级:
4.0.0 => 4.4.5的所有@角/*包6.1.0 => 6.5.7存储包在4.0.0和NgRedux 6.1.0中,这过去是工作的:
store = new NgRedux<IAppState>(null);
store.configureStore(reducerConfig, undefined);
// etc.但显然,他们制造了NgRedux级abstract。因此,如果出现以下异常,我的单元测试将失败:Cannot create an instance of the abstract class 'NgRedux'.
我试图通过使用测试剩余-测试简单操作上建议的自定义模拟类来修复我的测试
class MockRedux extends NgRedux<any> {
constructor() {
super(null);
}
dispatch = () => undefined;
}但是,由于没有实现所有具有以下错误的抽象成员,此操作失败:
[ts] Non-abstract class 'MockRedux' does not implement inherited abstract member 'configureSubStore' from class 'NgRedux<any>'.
因此出现了一个问题:我如何在我的角度规格中正确地模拟带有NgRedux的redux存储?
发布于 2017-10-19 12:09:32
我通过用NgRedux替换RootStore来解决这个问题
// without zone
let store = new NgRedux<IAppState>(null);
// with zone
let store = new RootStore<IAppState>(new NgZone({enableLongStackTrace: true}));这是因为RootStore是来自抽象NgRedux类的承继,如它们的repo中所示:
// store/src/components/root-store.ts
export class RootStore<RootState> extends NgRedux<RootState> {
private _store: Store<RootState>;
private _store$: BehaviorSubject<RootState>;
constructor(private ngZone: NgZone) {
super();
// etc.
}
//etc.
}https://stackoverflow.com/questions/46813126
复制相似问题