传递给下一个方法的值是当前
yield
是应该屈服的,而不是你测试的那个。试试这个:
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().value;
expect(topicId)
.toEqual(select(getNewTopicId));
});
it('should return groupId', () => {
groupId = generator.next(expectedTopicId).value;
expect(groupId)
.toEqual(select(getGroupId));
});
it('should redirect user to new topic screen', () => {
expect(generator.next(expectedGroupId).value)
.toEqual(put(push(getRouteUrl(routerUrls.TOPIC_CHAT.url, {
groupId,
topicId,
}))));
});
});