68346: Tests fixes

This commit is contained in:
Kristof De Langhe
2020-03-06 11:08:56 +01:00
parent cb21cd47bb
commit 4bbbc93f6c
9 changed files with 55 additions and 21 deletions

View File

@@ -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)),

View File

@@ -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 },

View File

@@ -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', () => {

View File

@@ -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(() => {

View File

@@ -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(), {

View File

@@ -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);
}
}

View File

@@ -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', () => {

View File

@@ -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<CollectionSearchResultGridElementComponent>;
@@ -68,6 +69,7 @@ describe('CollectionSearchResultGridElementComponent', () => {
{ provide: HttpClient, useValue: {} },
{ provide: DSOChangeAnalyzer, useValue: {} },
{ provide: DefaultChangeAnalyzer, useValue: {} },
{ provide: BitstreamFormatDataService, useValue: {} },
],
schemas: [ NO_ERRORS_SCHEMA ]

View File

@@ -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<CommunitySearchResultGridElementComponent>;
@@ -68,6 +69,7 @@ describe('CommunitySearchResultGridElementComponent', () => {
{ provide: HttpClient, useValue: {} },
{ provide: DSOChangeAnalyzer, useValue: {} },
{ provide: DefaultChangeAnalyzer, useValue: {} },
{ provide: BitstreamFormatDataService, useValue: {} },
],
schemas: [ NO_ERRORS_SCHEMA ]