Skip to content

Commit ea774b8

Browse files
[DURACOM-383] update tests
1 parent 1d35415 commit ea774b8

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

src/app/item-page/edit-item-page/item-delete/item-delete.component.spec.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fdescribe('ItemDeleteComponent', () => {
184184
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, ItemDeleteComponent, VarDirective],
185185
providers: [
186186
{ provide: ActivatedRoute, useValue: routeStub },
187-
{ provide: Router, useValue: routerStub },
187+
{ provide: Router, useValue: router },
188188
{ provide: ItemDataService, useValue: mockItemDataService },
189189
{ provide: NotificationsService, useValue: notificationsServiceStub },
190190
{ provide: ObjectUpdatesService, useValue: objectUpdatesServiceStub },
@@ -207,6 +207,7 @@ fdescribe('ItemDeleteComponent', () => {
207207
beforeEach(() => {
208208
fixture = TestBed.createComponent(ItemDeleteComponent);
209209
comp = fixture.componentInstance;
210+
expect(comp['router']).toBe(router);
210211
fixture.detectChanges();
211212
});
212213

@@ -237,25 +238,16 @@ fdescribe('ItemDeleteComponent', () => {
237238
done();
238239
}, 0);
239240
});
241+
240242
it('should show error notification and redirect to item edit page on failure', (done) => {
241243
scriptDataService.invoke.and.returnValue(createFailedRemoteDataObject$('Error', 500));
242244
comp.performAction();
243245
setTimeout(() => {
244-
expect(notificationService.error).toHaveBeenCalled();
245-
expect(router.navigate).toHaveBeenCalledWith([getItemEditRoute(mockItem)]);
246+
expect(comp['notificationsService'].error).toHaveBeenCalled();
247+
expect(comp['router'].navigate).toHaveBeenCalledWith([getItemEditRoute(mockItem)]);
246248
done();
247249
}, 0);
248250
});
249-
});
250-
describe('notify', () => {
251-
it('should navigate to the homepage on successful deletion of the item', () => {
252-
comp.notify(true);
253-
expect(routerStub.navigate).toHaveBeenCalledWith(['']);
254-
});
255251

256-
it('should navigate to the item edit page on failed deletion of the item', () => {
257-
comp.notify(false);
258-
expect(routerStub.navigate).toHaveBeenCalledWith([getItemEditRoute(mockItem)]);
259-
});
260252
});
261253
});

0 commit comments

Comments
 (0)