При отладке теста visitFilterReducer заполняется значением, переданным в следующую функцию. Однако при втором вызове генератора currentPositionReducer возвращает undefined?
const filterReducer = {
sort: SortType.NearMe,
filter: FilterType.All,
dateFilter: DateFilterType.All,
dateFilterDate: "",
} as IVisitFilterState;
const currentPositionReducer = {
currentPosition: { latitude: 1, longitude: 2 },
} as ICurrentPositionState;
expect(
generator.next({
...filterReducer,
...currentPositionReducer, // typescript forces me to set this?
}).value,
).toEqual(select(visitFilterSelector));
expect(
generator.next({
...filterReducer,
...currentPositionReducer,
}).value,
).toEqual(select(currentPositionSelector));
// Тестируемый код
export const visitFilterSelector = (state: RootState): IVisitFilterState =>
state.VisitFilterReducer;
export const currentPositionSelector = (
state: RootState,
): ICurrentPositionState => {
return state.CurrentPositionReducer;
};
const visitFilterReducer: IVisitFilterState = yield select(
visitFilterSelector,
);
const { sort, filter, dateFilter, dateFilterDate } = visitFilterReducer;
const currentPositionReducer: ICurrentPositionState = yield select(
currentPositionSelector,
);
const { currentPosition } = currentPositionReducer;