From 4bbbc93f6cea2c9e31324c89235963183b576cff Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Fri, 6 Mar 2020 11:08:56 +0100 Subject: [PATCH] 68346: Tests fixes --- .../edit-bitstream-page.component.spec.ts | 32 +++++++++++++------ .../upload/upload-bitstream.component.spec.ts | 6 ++-- .../item-bitstreams.component.spec.ts | 13 ++++++-- ...em-edit-bitstream-bundle.component.spec.ts | 4 ++- ...-and-drop-bitstream-list.component.spec.ts | 4 ++- .../cache/server-sync-buffer.effects.spec.ts | 7 ++-- .../core/data/bitstream-data.service.spec.ts | 6 ++-- ...arch-result-grid-element.component.spec.ts | 2 ++ ...arch-result-grid-element.component.spec.ts | 2 ++ 9 files changed, 55 insertions(+), 21 deletions(-) diff --git a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts index b9d14c7703..18201c6cb6 100644 --- a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts +++ b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts @@ -41,24 +41,33 @@ describe('EditBitstreamPageComponent', () => { beforeEach(async(() => { allFormats = [ - { + Object.assign({ id: '1', shortDescription: 'Unknown', description: 'Unknown format', - supportLevel: BitstreamFormatSupportLevel.Unknown - }, - { + supportLevel: BitstreamFormatSupportLevel.Unknown, + _links: { + self: { href: 'format-selflink-1' } + } + }), + Object.assign({ id: '2', shortDescription: 'PNG', description: 'Portable Network Graphics', - supportLevel: BitstreamFormatSupportLevel.Known - }, - { + supportLevel: BitstreamFormatSupportLevel.Known, + _links: { + self: { href: 'format-selflink-2' } + } + }), + Object.assign({ id: '3', shortDescription: 'GIF', description: 'Graphics Interchange Format', - supportLevel: BitstreamFormatSupportLevel.Known - } + supportLevel: BitstreamFormatSupportLevel.Known, + _links: { + self: { href: 'format-selflink-3' } + } + }) ] as BitstreamFormat[]; selectedFormat = allFormats[1]; notificationsService = jasmine.createSpyObj('notificationsService', @@ -93,7 +102,10 @@ describe('EditBitstreamPageComponent', () => { } ] }, - format: observableOf(new RemoteData(false, false, true, null, selectedFormat)) + format: observableOf(new RemoteData(false, false, true, null, selectedFormat)), + _links: { + self: 'bitstream-selflink' + } }); bitstreamService = jasmine.createSpyObj('bitstreamService', { findById: observableOf(new RemoteData(false, false, true, null, bitstream)), diff --git a/src/app/+item-page/bitstreams/upload/upload-bitstream.component.spec.ts b/src/app/+item-page/bitstreams/upload/upload-bitstream.component.spec.ts index c7aa267dc5..3fe1afad19 100644 --- a/src/app/+item-page/bitstreams/upload/upload-bitstream.component.spec.ts +++ b/src/app/+item-page/bitstreams/upload/upload-bitstream.component.spec.ts @@ -31,7 +31,9 @@ describe('UploadBistreamComponent', () => { const bundle = Object.assign(new Bundle(), { id: 'bundle', uuid: 'bundle', - self: 'bundle-selflink' + _links: { + self: { href: 'bundle-selflink' } + } }); const itemName = 'fake-name'; const mockItem = Object.assign(new Item(), { @@ -112,7 +114,7 @@ describe('UploadBistreamComponent', () => { }; TestBed.configureTestingModule({ - imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()], + imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule], declarations: [UploadBitstreamComponent, VarDirective], providers: [ { provide: ActivatedRoute, useValue: routeStub }, diff --git a/src/app/+item-page/edit-item-page/item-bitstreams/item-bitstreams.component.spec.ts b/src/app/+item-page/edit-item-page/item-bitstreams/item-bitstreams.component.spec.ts index 45bea14efb..334d3ce753 100644 --- a/src/app/+item-page/edit-item-page/item-bitstreams/item-bitstreams.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-bitstreams/item-bitstreams.component.spec.ts @@ -35,9 +35,11 @@ const infoNotification: INotification = new Notification('id', NotificationType. const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning'); const successNotification: INotification = new Notification('id', NotificationType.Success, 'success'); const bitstream1 = Object.assign(new Bitstream(), { + id: 'bitstream1', uuid: 'bitstream1' }); const bitstream2 = Object.assign(new Bitstream(), { + id: 'bitstream2', uuid: 'bitstream2' }); const fieldUpdate1 = { @@ -51,7 +53,9 @@ const fieldUpdate2 = { const bundle = Object.assign(new Bundle(), { id: 'bundle1', uuid: 'bundle1', - self: 'bundle1-selflink', + _links: { + self: { href: 'bundle1-selflink' } + }, bitstreams: createMockRDPaginatedObs([bitstream1, bitstream2]) }); const moveOperations = [ @@ -124,6 +128,9 @@ describe('ItemBitstreamsComponent', () => { item = Object.assign(new Item(), { uuid: 'item', id: 'item', + _links: { + self: { href: 'item-selflink' } + }, bundles: createMockRDPaginatedObs([bundle]), lastModified: date }); @@ -177,11 +184,11 @@ describe('ItemBitstreamsComponent', () => { }); it('should call deleteAndReturnResponse on the bitstreamService for the marked field', () => { - expect(bitstreamService.deleteAndReturnResponse).toHaveBeenCalledWith(bitstream2); + expect(bitstreamService.deleteAndReturnResponse).toHaveBeenCalledWith(bitstream2.id); }); it('should not call deleteAndReturnResponse on the bitstreamService for the unmarked field', () => { - expect(bitstreamService.deleteAndReturnResponse).not.toHaveBeenCalledWith(bitstream1); + expect(bitstreamService.deleteAndReturnResponse).not.toHaveBeenCalledWith(bitstream1.id); }); it('should send out a patch for the move operations', () => { diff --git a/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.spec.ts b/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.spec.ts index a3a02bce9b..e15a9d7996 100644 --- a/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.spec.ts @@ -26,7 +26,9 @@ describe('ItemEditBitstreamBundleComponent', () => { const bundle = Object.assign(new Bundle(), { id: 'bundle-1', uuid: 'bundle-1', - self: 'bundle-1-selflink' + _links: { + self: { href: 'bundle-1-selflink' } + } }); beforeEach(async(() => { diff --git a/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.spec.ts b/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.spec.ts index dc5c65af30..704fa0122e 100644 --- a/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.spec.ts @@ -32,7 +32,9 @@ describe('PaginatedDragAndDropBitstreamListComponent', () => { const bundle = Object.assign(new Bundle(), { id: 'bundle-1', uuid: 'bundle-1', - self: 'bundle-1-selflink' + _links: { + self: { href: 'bundle-1-selflink' } + } }); const date = new Date(); const format = Object.assign(new BitstreamFormat(), { diff --git a/src/app/core/cache/server-sync-buffer.effects.spec.ts b/src/app/core/cache/server-sync-buffer.effects.spec.ts index 3cdde3c2c6..c2aa7b14f9 100644 --- a/src/app/core/cache/server-sync-buffer.effects.spec.ts +++ b/src/app/core/cache/server-sync-buffer.effects.spec.ts @@ -53,8 +53,11 @@ describe('ServerSyncBufferEffects', () => { return observableOf(object); }, getBySelfLink: (link) => { - const object = new DSpaceObject(); - object.self = link; + const object = Object.assign(new DSpaceObject(), { + _links: { + self: { href: link } + } + }); return observableOf(object); } } diff --git a/src/app/core/data/bitstream-data.service.spec.ts b/src/app/core/data/bitstream-data.service.spec.ts index 8ab02fa65e..fca0f6b650 100644 --- a/src/app/core/data/bitstream-data.service.spec.ts +++ b/src/app/core/data/bitstream-data.service.spec.ts @@ -21,7 +21,9 @@ describe('BitstreamDataService', () => { const bitstream = Object.assign(new Bitstream(), { uuid: 'fake-bitstream', - self: 'fake-bitstream-self' + _links: { + self: { href: 'fake-bitstream-self' } + } }); const format = Object.assign(new BitstreamFormat(), { id: '2', @@ -41,7 +43,7 @@ describe('BitstreamDataService', () => { getBrowseEndpoint: observableOf(bitstreamFormatHref) }); - service = new BitstreamDataService(requestService, null, null, null, null, objectCache, halService, null, null, null, bitstreamFormatService); + service = new BitstreamDataService(requestService, null, null, null, objectCache, halService, null, null, null, null, bitstreamFormatService); }); describe('when updating the bitstream\'s format', () => { diff --git a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.spec.ts index c14e3f6df1..1cb0819c4e 100644 --- a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.spec.ts @@ -17,6 +17,7 @@ import { CollectionSearchResult } from '../../../object-collection/shared/collec import { TruncatableService } from '../../../truncatable/truncatable.service'; import { TruncatePipe } from '../../../utils/truncate.pipe'; import { CollectionSearchResultGridElementComponent } from './collection-search-result-grid-element.component'; +import { BitstreamFormatDataService } from '../../../../core/data/bitstream-format-data.service'; let collectionSearchResultGridElementComponent: CollectionSearchResultGridElementComponent; let fixture: ComponentFixture; @@ -68,6 +69,7 @@ describe('CollectionSearchResultGridElementComponent', () => { { provide: HttpClient, useValue: {} }, { provide: DSOChangeAnalyzer, useValue: {} }, { provide: DefaultChangeAnalyzer, useValue: {} }, + { provide: BitstreamFormatDataService, useValue: {} }, ], schemas: [ NO_ERRORS_SCHEMA ] diff --git a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.spec.ts index 0ea72b52d5..c699163631 100644 --- a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.spec.ts @@ -17,6 +17,7 @@ import { CommunitySearchResult } from '../../../object-collection/shared/communi import { TruncatableService } from '../../../truncatable/truncatable.service'; import { TruncatePipe } from '../../../utils/truncate.pipe'; import { CommunitySearchResultGridElementComponent } from './community-search-result-grid-element.component'; +import { BitstreamFormatDataService } from '../../../../core/data/bitstream-format-data.service'; let communitySearchResultGridElementComponent: CommunitySearchResultGridElementComponent; let fixture: ComponentFixture; @@ -68,6 +69,7 @@ describe('CommunitySearchResultGridElementComponent', () => { { provide: HttpClient, useValue: {} }, { provide: DSOChangeAnalyzer, useValue: {} }, { provide: DefaultChangeAnalyzer, useValue: {} }, + { provide: BitstreamFormatDataService, useValue: {} }, ], schemas: [ NO_ERRORS_SCHEMA ]