【发布时间】:2021-08-13 17:13:09
【问题描述】:
是否可以测试 eventAggregator.publish 是否在另一个发布期间执行?
this.eventAggregator.with(this).subscribe(Xevent, (event: Xevent) => {
this.eventAggregator.publish(new anotherEvent());
});
如果我这样测试:
describe('when X event is published', () => {
it('then Y event should be published', () => {
//arrange
let event = new Xevent();
spyOn(evtAggregator, 'publish');
//act
evtAggregator.publish(event);
//assert
expect(evtAggregator.publish).toHaveBeenCalledWith(new anotherEvent());
});
});
jasmine 给我一个错误,事件聚合器是用“Xevent”调用的:
预期的间谍发布已被 [ anotherEvent ... ] 调用 但实际调用是 [Xevent ...]
我可以用不同的方式断言它还是我在排列部分中缺少了什么?
【问题讨论】:
标签: angularjs unit-testing jasmine