Reputation: 43
I am not able to get reducer state value inside spec ts. Getting below error.
An error was thrown in afterAll TypeError: Cannot read properties of undefined (reading 'isLoading')
app.component.ts:
let isLoading:Boolean;
public isLoadingValue(){
this._store$
.pipe(
takeUntil(this._destroy$),
select((store: IStore) => store.dsPowerCreateReducer.isLoading),//Getting error for isLoading
)
.subscribe((isLoading: boolean) => {
this.isLoading = isLoading;
});
}
app.component.spec.ts:
it('should set isLoading correctly', () => {
spyOn(store, 'pipe').and.returnValue(of(true));
component.isLoading = true;
component.isLoadingValue();//Getting Error for isLoading
expect(component.isLoading).toBeTrue();
});
i-create.ts
export interface ICreateReducerState {
isLoading: boolean;
meta: any;
}
reducer.ts:
import { ICreateReducerState } from "./i-create";
export class NewCreateApiReducer {
public static readonly _initialState: ICreateReducerState = {
isLoading: false,
meta: null,
};
}
store.ts:
readonly dsPowerCreateReducer: ICreateReducerState;
Upvotes: 0
Views: 18