mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
Fixed feedback
This commit is contained in:
@@ -27,8 +27,6 @@ let routerStub;
|
||||
let mockItemDataService: ItemDataService;
|
||||
let routeStub;
|
||||
let notificationsServiceStub;
|
||||
let successfulRestResponse;
|
||||
let failRestResponse;
|
||||
|
||||
describe('ItemDeleteComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
@@ -46,14 +44,12 @@ describe('ItemDeleteComponent', () => {
|
||||
});
|
||||
|
||||
mockItemDataService = jasmine.createSpyObj('mockItemDataService', {
|
||||
delete: observableOf(new RestResponse(true, '200'))
|
||||
delete: observableOf(true)
|
||||
});
|
||||
|
||||
routeStub = {
|
||||
data: observableOf({
|
||||
item: new RemoteData(false, false, true, null, {
|
||||
id: 'fake-id'
|
||||
})
|
||||
item: new RemoteData(false, false, true, null, mockItem)
|
||||
})
|
||||
};
|
||||
|
||||
@@ -63,10 +59,10 @@ describe('ItemDeleteComponent', () => {
|
||||
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [ItemDeleteComponent],
|
||||
providers: [
|
||||
{provide: ActivatedRoute, useValue: routeStub},
|
||||
{provide: Router, useValue: routerStub},
|
||||
{provide: ItemDataService, useValue: mockItemDataService},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||
{ provide: ActivatedRoute, useValue: routeStub },
|
||||
{ provide: Router, useValue: routerStub },
|
||||
{ provide: ItemDataService, useValue: mockItemDataService },
|
||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||
], schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA
|
||||
]
|
||||
@@ -74,9 +70,6 @@ describe('ItemDeleteComponent', () => {
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
successfulRestResponse = new RestResponse(true, '200');
|
||||
failRestResponse = new RestResponse(false, '500');
|
||||
|
||||
fixture = TestBed.createComponent(ItemDeleteComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
@@ -95,22 +88,21 @@ describe('ItemDeleteComponent', () => {
|
||||
|
||||
describe('performAction', () => {
|
||||
it('should call delete function from the ItemDataService', () => {
|
||||
spyOn(comp, 'processRestResponse');
|
||||
spyOn(comp, 'notify');
|
||||
comp.performAction();
|
||||
|
||||
expect(mockItemDataService.delete).toHaveBeenCalledWith(mockItem.id);
|
||||
expect(comp.processRestResponse).toHaveBeenCalled();
|
||||
expect(mockItemDataService.delete).toHaveBeenCalledWith(mockItem);
|
||||
expect(comp.notify).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
describe('processRestResponse', () => {
|
||||
describe('notify', () => {
|
||||
it('should navigate to the homepage on successful deletion of the item', () => {
|
||||
comp.processRestResponse(successfulRestResponse);
|
||||
comp.notify(true);
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith(['']);
|
||||
});
|
||||
});
|
||||
describe('processRestResponse', () => {
|
||||
describe('notify', () => {
|
||||
it('should navigate to the item edit page on failed deletion of the item', () => {
|
||||
comp.processRestResponse(failRestResponse);
|
||||
comp.notify(false);
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith([getItemEditPath('fake-id')]);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user