【发布时间】:2020-03-12 13:12:34
【问题描述】:
如何传递事件模拟对象并获得验证
onCallFunction() {
const eventValue = event;
if (!eventValue.relatedTarget || !eventValue.relatedTarget.last.contain('value')) {
super.onCallFunction();
}
}
在 Testbed 中声明事件 const 但无法理解如何传递给函数以执行代码
describe('relatedTarget test', () => {
compoenent = fixture.componentInstance;
it('should have value for property newValue', () {
spyOn('component', 'onCallFunction');
const event = {event:
{
relatedTarget:
{
last: {
contain: (param) => {}
}
}
}};
component.onCallFunction();
expect(component.onCallFunction).toHaveBeenCalled();
})
});
【问题讨论】:
标签: javascript angular jasmine