Here is the method i am trying to test:
showSnackbar(): void {
if (this.modifiedReferences.length) {
const snackbar = this.snackbarService.open({
message: '',
type: 'success',
duration: 10000,
actionText: 'SHOW DETAILS'
});
snackbar.instance.actionClicked.subscribe(() => {
this.dialogService.modal(ModifiedComponent);
});
}
}
and here is the test:
it('should call the showSnackbar method', () => {
const showSnackbarSpy: jasmine.Spy = spyOn(TestBed.inject(SnackbarService), 'open');
component.showSnackbar();
expect(showSnackbarSpy).toHaveBeenCalled();
});
When i try to test it displays zn error saying that it can't reag property 'instance' of undefined
Aucun commentaire:
Enregistrer un commentaire