使用冷热的茉莉花弹珠的时间/框架问题
Timing / Framing issue with Jasmine-marbles using hot and cold
我有一个快速演示,人们可以在这里下载:https://stackblitz.com/edit/angular-vczzqp只需在您最喜欢的终端中点击右上角的导出,然后 运行 install
和 ng test
使用您最喜欢的浏览器。
基本上,对我来说,问题似乎是 Jasmine 的内部时序与对象不匹配。
下面是测试以及我得到的确切错误。有关完整测试,请参阅 app/Test 下的示例 class
it('should return a GET_GENERIC_FAILED when the services throws', () => {
const action = new genericActions.GetAllGenericAction();
genericsService.getAllGenerics.and.returnValue(Observable.throw({}));
actions$.stream = hot('a', { a: action });
const expected = cold('b', { b: new genericActions.GetGenericFailedAction() });
expect(effects.getAllGenerics).toBeObservable(expected);
});
错误
Expected
[Object({
frame: 0,
notification: Notification({
kind: 'N',
value: GetGenericFailedAction({
type: '[GENERIC] Get Generic Failed'
}),
error: undefined,
hasValue: true
})
}), Object({
frame: 0,
notification: Notification({
kind: 'C',
value: undefined,
error: undefined,
hasValue: false
})
})]
to equal
[Object({
frame: 0,
notification: Notification({
kind: 'N',
value: GetGenericFailedAction({
type: '[GENERIC] Get Generic Failed'
}),
error: undefined,
hasValue: true
})
})].
如有任何指导,我们将不胜感激。
我有一个快速演示,人们可以在这里下载:https://stackblitz.com/edit/angular-vczzqp只需在您最喜欢的终端中点击右上角的导出,然后 运行 install
和 ng test
使用您最喜欢的浏览器。
基本上,对我来说,问题似乎是 Jasmine 的内部时序与对象不匹配。
下面是测试以及我得到的确切错误。有关完整测试,请参阅 app/Test 下的示例 class
it('should return a GET_GENERIC_FAILED when the services throws', () => {
const action = new genericActions.GetAllGenericAction();
genericsService.getAllGenerics.and.returnValue(Observable.throw({}));
actions$.stream = hot('a', { a: action });
const expected = cold('b', { b: new genericActions.GetGenericFailedAction() });
expect(effects.getAllGenerics).toBeObservable(expected);
});
错误
Expected
[Object({
frame: 0,
notification: Notification({
kind: 'N',
value: GetGenericFailedAction({
type: '[GENERIC] Get Generic Failed'
}),
error: undefined,
hasValue: true
})
}), Object({
frame: 0,
notification: Notification({
kind: 'C',
value: undefined,
error: undefined,
hasValue: false
})
})]
to equal
[Object({
frame: 0,
notification: Notification({
kind: 'N',
value: GetGenericFailedAction({
type: '[GENERIC] Get Generic Failed'
}),
error: undefined,
hasValue: true
})
})].
如有任何指导,我们将不胜感激。