Я действительно запутался в том, как написать тестовый блок для этой функции.
onDelete(event) {
this.confirm.confirm({
title: 'something',
message: 'something'
}).then((res) => {
if (res) {
this.machineService.delete(event.data.id);
}
}, () => {
});
}
Я пытался
describe('onDelete method', () => {
it('should delete as the data provided by the event', () => {
const {comp, fixture} = setup();
const machine = initialMachine;
const event = { data: machine };
const machineServiceStub: MachineService = fixture.debugElement.injector.get(MachineService);
const appConfirmServiceStub: AppConfirmService = fixture.debugElement.injector.get(AppConfirmService);
spyOn(appConfirmServiceStub, 'confirm').and.returnValue(true);
spyOn(machineServiceStub, 'delete');
comp.onDelete(event);
expect(appConfirmServiceStub.confirm).toHaveBeenCalled();
});
});
Я получаю эту ошибку
this.confirm.confirm (...). Тогда это не функция, может кто-нибудь, пожалуйста,помоги мне с этим.Спасибо