I'm running my ui test with Karma on Jhipster with "yarn test" command.
My tests run normal, but in one of my "dialog component" tests, i have this error.
Component Tests Project Management Dialog Component save Should call create service on save for new entity FAILED
I did my reasearch on google about this error but i couldn't find anything. The message it's pretty clear, it should call create method on service.
This is my code on "save()" method on project-dialog.component.ts:
save() {
this.isSaving = true;
if (this.project.id !== undefined) {
this.subscribeToSaveResponse(
this.projectService.update(this.project));
} else {
this.subscribeToSaveResponse(
this.projectService.create(this.project));
}
}
And my project-dialog.component.spec.ts Test code for that part is:
it('Should call create service on save for new entity',
inject([],
fakeAsync(() => {
// GIVEN
const entity = new Project();
spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({body: entity})));
comp.project = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'projectListModification', content: 'OK'});
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
})
)
);
I don't know why is this test failing, does anyone has an idea?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire