87968: Fix unit tests

This commit is contained in:
Yura Bondarenko
2022-03-03 18:44:55 +01:00
parent 26d45fd5e7
commit ae89571519
6 changed files with 49 additions and 36 deletions

View File

@@ -132,22 +132,27 @@ describe('WorkspaceitemActionsComponent', () => {
expect(btn).toBeDefined();
});
it('should call confirmDiscard on discard confirmation', () => {
mockDataService.delete.and.returnValue(observableOf(true));
spyOn(component, 'reload');
const btn = fixture.debugElement.query(By.css('.btn-danger'));
btn.nativeElement.click();
fixture.detectChanges();
describe('on discard confirmation', () => {
beforeEach((done) => {
mockDataService.delete.and.returnValue(observableOf(true));
spyOn(component, 'reload');
const btn = fixture.debugElement.query(By.css('.btn-danger'));
btn.nativeElement.click();
fixture.detectChanges();
const confirmBtn: any = ((document as any).querySelector('.modal-footer .btn-danger'));
confirmBtn.click();
const confirmBtn: any = ((document as any).querySelector('.modal-footer .btn-danger'));
confirmBtn.click();
fixture.detectChanges();
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(mockDataService.delete).toHaveBeenCalledWith(mockObject.id);
fixture.whenStable().then(() => {
done();
});
});
it('should call confirmDiscard', () => {
expect(mockDataService.delete).toHaveBeenCalledWith(mockObject.id);
});
});
it('should display a success notification on delete success', waitForAsync(() => {