62589: Post-Merge Tests and error fixes

This commit is contained in:
Kristof De Langhe
2019-05-28 17:03:57 +02:00
parent 2b1fd76365
commit 045b87c1c8
3 changed files with 8 additions and 23 deletions

View File

@@ -72,7 +72,7 @@ describe('CollectionItemMapperComponent', () => {
paginatedSearchOptions: mockSearchOptions paginatedSearchOptions: mockSearchOptions
}; };
const itemDataServiceStub = { const itemDataServiceStub = {
mapToCollection: () => of(new RestResponse(true, '200')) mapToCollection: () => of(new RestResponse(true, 200, 'OK'))
}; };
const activatedRouteStub = new ActivatedRouteStub({}, { collection: mockCollectionRD }); const activatedRouteStub = new ActivatedRouteStub({}, { collection: mockCollectionRD });
const translateServiceStub = { const translateServiceStub = {
@@ -134,11 +134,6 @@ describe('CollectionItemMapperComponent', () => {
describe('mapItems', () => { describe('mapItems', () => {
const ids = ['id1', 'id2', 'id3', 'id4']; const ids = ['id1', 'id2', 'id3', 'id4'];
beforeEach(() => {
spyOn(notificationsService, 'success').and.callThrough();
spyOn(notificationsService, 'error').and.callThrough();
});
it('should display a success message if at least one mapping was successful', () => { it('should display a success message if at least one mapping was successful', () => {
comp.mapItems(ids); comp.mapItems(ids);
expect(notificationsService.success).toHaveBeenCalled(); expect(notificationsService.success).toHaveBeenCalled();
@@ -146,7 +141,7 @@ describe('CollectionItemMapperComponent', () => {
}); });
it('should display an error message if at least one mapping was unsuccessful', () => { it('should display an error message if at least one mapping was unsuccessful', () => {
spyOn(itemDataService, 'mapToCollection').and.returnValue(of(new RestResponse(false, '404'))); spyOn(itemDataService, 'mapToCollection').and.returnValue(of(new RestResponse(false, 404, 'Not Found')));
comp.mapItems(ids); comp.mapItems(ids);
expect(notificationsService.success).not.toHaveBeenCalled(); expect(notificationsService.success).not.toHaveBeenCalled();
expect(notificationsService.error).toHaveBeenCalled(); expect(notificationsService.error).toHaveBeenCalled();

View File

@@ -69,8 +69,8 @@ describe('ItemCollectionMapperComponent', () => {
}; };
const mockCollectionsRD = new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), [])); const mockCollectionsRD = new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), []));
const itemDataServiceStub = { const itemDataServiceStub = {
mapToCollection: () => of(new RestResponse(true, '200')), mapToCollection: () => of(new RestResponse(true, 200, 'OK')),
removeMappingFromCollection: () => of(new RestResponse(true, '200')), removeMappingFromCollection: () => of(new RestResponse(true, 200, 'OK')),
getMappedCollections: () => of(mockCollectionsRD), getMappedCollections: () => of(mockCollectionsRD),
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
clearMappedCollectionsRequests: () => {} clearMappedCollectionsRequests: () => {}
@@ -128,11 +128,6 @@ describe('ItemCollectionMapperComponent', () => {
describe('mapCollections', () => { describe('mapCollections', () => {
const ids = ['id1', 'id2', 'id3', 'id4']; const ids = ['id1', 'id2', 'id3', 'id4'];
beforeEach(() => {
spyOn(notificationsService, 'success').and.callThrough();
spyOn(notificationsService, 'error').and.callThrough();
});
it('should display a success message if at least one mapping was successful', () => { it('should display a success message if at least one mapping was successful', () => {
comp.mapCollections(ids); comp.mapCollections(ids);
expect(notificationsService.success).toHaveBeenCalled(); expect(notificationsService.success).toHaveBeenCalled();
@@ -140,7 +135,7 @@ describe('ItemCollectionMapperComponent', () => {
}); });
it('should display an error message if at least one mapping was unsuccessful', () => { it('should display an error message if at least one mapping was unsuccessful', () => {
spyOn(itemDataService, 'mapToCollection').and.returnValue(of(new RestResponse(false, '404'))); spyOn(itemDataService, 'mapToCollection').and.returnValue(of(new RestResponse(false, 404, 'Not Found')));
comp.mapCollections(ids); comp.mapCollections(ids);
expect(notificationsService.success).not.toHaveBeenCalled(); expect(notificationsService.success).not.toHaveBeenCalled();
expect(notificationsService.error).toHaveBeenCalled(); expect(notificationsService.error).toHaveBeenCalled();
@@ -150,11 +145,6 @@ describe('ItemCollectionMapperComponent', () => {
describe('removeMappings', () => { describe('removeMappings', () => {
const ids = ['id1', 'id2', 'id3', 'id4']; const ids = ['id1', 'id2', 'id3', 'id4'];
beforeEach(() => {
spyOn(notificationsService, 'success').and.callThrough();
spyOn(notificationsService, 'error').and.callThrough();
});
it('should display a success message if the removal of at least one mapping was successful', () => { it('should display a success message if the removal of at least one mapping was successful', () => {
comp.removeMappings(ids); comp.removeMappings(ids);
expect(notificationsService.success).toHaveBeenCalled(); expect(notificationsService.success).toHaveBeenCalled();
@@ -162,7 +152,7 @@ describe('ItemCollectionMapperComponent', () => {
}); });
it('should display an error message if the removal of at least one mapping was unsuccessful', () => { it('should display an error message if the removal of at least one mapping was unsuccessful', () => {
spyOn(itemDataService, 'removeMappingFromCollection').and.returnValue(of(new RestResponse(false, '404'))); spyOn(itemDataService, 'removeMappingFromCollection').and.returnValue(of(new RestResponse(false, 404, 'Not Found')));
comp.removeMappings(ids); comp.removeMappings(ids);
expect(notificationsService.success).not.toHaveBeenCalled(); expect(notificationsService.success).not.toHaveBeenCalled();
expect(notificationsService.error).toHaveBeenCalled(); expect(notificationsService.error).toHaveBeenCalled();

View File

@@ -20,8 +20,8 @@
<tr *ngFor="let item of itemsRD?.payload?.page"> <tr *ngFor="let item of itemsRD?.payload?.page">
<td><input class="item-checkbox" [ngModel]="getSelected(item.id) | async" (change)="switch(item.id)" type="checkbox" name="{{item.id}}"></td> <td><input class="item-checkbox" [ngModel]="getSelected(item.id) | async" (change)="switch(item.id)" type="checkbox" name="{{item.id}}"></td>
<td *ngIf="!hideCollection"><a [routerLink]="['/items', item.id]">{{(item.owningCollection | async)?.payload?.name}}</a></td> <td *ngIf="!hideCollection"><a [routerLink]="['/items', item.id]">{{(item.owningCollection | async)?.payload?.name}}</a></td>
<td><a *ngIf="item.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']).length > 0" [routerLink]="['/items', item.id]">{{item.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])[0].value}}</a></td> <td><a *ngIf="item.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])" [routerLink]="['/items', item.id]">{{item.firstMetadataValue(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])}}</a></td>
<td><a [routerLink]="['/items', item.id]">{{item.findMetadata("dc.title")}}</a></td> <td><a [routerLink]="['/items', item.id]">{{item.firstMetadataValue("dc.title")}}</a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>