У меня есть сага с функциями выбора, которые должны взять пару сведений из состояния и использовать их для перехода на новый URL.
КОД ДЛЯ САГА:
export function* appRedirectToNewTopic() {
const getCreatingNewTopicError = yield select(getCreatingTopicError);
const newTopicId = yield select(getNewTopicId);
const groupId = yield select(getGroupId);
if (isEmpty(getCreatingNewTopicError)) { // this is lodash isEmpty
yield put(push(getRouteUrl(routerUrls.TOPIC_CHAT.url, {
groupId,
topicId: newTopicId,
})));
} // TODO add here when notification is made
}
КОД ДЛЯ ТЕСТА САГА:
describe('appRedirectToNewTopic', () => {
const action = appCreateNewTopicFinishedAction();
const generator =
cloneableGenerator(appRedirectToNewTopic)(action);
const expectedGroupId = {
apiGroups: {
groupInfo: {
groupInfo: {
id: 466,
},
},
},
};
const expectedTopicId = {
apiTopics: {
newTopicId: 22466,
},
};
let topicId;
let groupId;
it('should return empty error', () => {
expect(generator.next().value)
.toEqual(select(getCreatingTopicError));
});
it('should return new topicId', () => {
topicId = generator.next(expectedTopicId).value;
expect(topicId)
.toEqual(select(getNewTopicId));
});
it('should return groupId', () => {
groupId = generator.next(expectedGroupId).value;
expect(groupId)
.toEqual(select(getGroupId));
});
it('should redirect user to new topic screen', () => {
expect(generator.next().value)
.toEqual(put(push(getRouteUrl(routerUrls.TOPIC_CHAT.url, {
groupId,
topicId,
}))));
});
});
Ошибка, которую я получаю, должна перенаправить пользователя в новую тему, и ошибка Expected value to equal:
{"@@redux-saga/IO": true, "PUT": {"action": {"payload": {"args": ["/chat/[object Object]/[object Object]"], "method": "push"}, "type": "@@router/CALL_HISTORY_METHOD"}, "channel": null}}
Received:
undefined