All edit component tests are running and passing

This commit is contained in:
Michael Spalti
2021-12-05 18:24:16 -08:00
parent e521f2d579
commit fe5b7663e9

View File

@@ -22,6 +22,7 @@ import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } f
import { getEntityEditRoute } from '../../item-page/item-page-routing-paths';
import { createPaginatedList } from '../../shared/testing/utils.test';
import { Item } from '../../core/shared/item.model';
import { MetadataValueFilter } from '../../core/shared/metadata.models';
const infoNotification: INotification = new Notification('id', NotificationType.Info, 'info');
const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning');
@@ -30,17 +31,16 @@ const successNotification: INotification = new Notification('id', NotificationTy
let notificationsService: NotificationsService;
let formService: DynamicFormService;
let bitstreamService: BitstreamDataService;
let bitstreamServiceIIIF: BitstreamDataService;
let bitstreamFormatService: BitstreamFormatDataService;
let bitstream: Bitstream;
let bitstreamIIIFItem: Bitstream;
let selectedFormat: BitstreamFormat;
let allFormats: BitstreamFormat[];
let router: Router;
let comp: EditBitstreamPageComponent;
let fixture: ComponentFixture<EditBitstreamPageComponent>;
describe('EditBitstreamPageComponent', () => {
let comp: EditBitstreamPageComponent;
let fixture: ComponentFixture<EditBitstreamPageComponent>;
beforeEach(waitForAsync(() => {
allFormats = [
@@ -92,9 +92,6 @@ describe('EditBitstreamPageComponent', () => {
return undefined;
}
});
describe('EditBitstreamPageComponent without IIIF fields', () => {
beforeEach(waitForAsync(() => {
bitstream = Object.assign(new Bitstream(), {
metadata: {
'dc.description': [
@@ -115,11 +112,19 @@ describe('EditBitstreamPageComponent', () => {
bundle: createSuccessfulRemoteDataObject$({
item: createSuccessfulRemoteDataObject$(Object.assign(new Item(), {
uuid: 'some-uuid',
firstMetadataValue: () => '',
firstMetadataValue(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter): string {
return undefined;
},
}))
})
});
bitstreamService = jasmine.createSpyObj('bitstreamService', {
findById: createSuccessfulRemoteDataObject$(bitstream),
update: createSuccessfulRemoteDataObject$(bitstream),
updateFormat: createSuccessfulRemoteDataObject$(bitstream),
commitUpdates: {},
patch: {}
});
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
findAll: createSuccessfulRemoteDataObject$(createPaginatedList(allFormats))
});
@@ -142,6 +147,7 @@ describe('EditBitstreamPageComponent', () => {
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
}));
beforeEach(() => {
@@ -174,12 +180,6 @@ describe('EditBitstreamPageComponent', () => {
it('should put the \"New Format\" input on invisible', () => {
expect(comp.formLayout.newFormat.grid.host).toContain('invisible');
});
it('should put the \"IIIF Label\" input to be display: none', () => {
expect(comp.formLayout.iiifLabel.grid.host).toContain('d-none');
});
it('should set isIIIF to false', () => {
expect(comp.isIIIF).toBeFalse();
});
});
describe('when an unknown format is selected', () => {
@@ -252,10 +252,9 @@ describe('EditBitstreamPageComponent', () => {
expect(router.navigate).toHaveBeenCalledWith([getEntityEditRoute(null, 'some-uuid'), 'bitstreams']);
});
});
});
});
describe('EditBitstreamPageComponent with IIIF', () => {
describe('EditBitstreamPageComponent with IIIF', () => {
beforeEach(waitForAsync(() => {
bitstreamService = jasmine.createSpyObj('bitstreamService', {
@@ -265,7 +264,7 @@ describe('EditBitstreamPageComponent', () => {
commitUpdates: {},
patch: {}
});
bitstreamIIIFItem = Object.assign(new Bitstream(), {
bitstream = Object.assign(new Bitstream(), {
metadata: {
'dc.description': [
{
@@ -305,22 +304,16 @@ describe('EditBitstreamPageComponent', () => {
bundle: createSuccessfulRemoteDataObject$({
item: createSuccessfulRemoteDataObject$(Object.assign(new Item(), {
uuid: 'some-uuid',
firstMetadataValue: () => 'true',
metadata: {
'dspace.iiif.enabled': [
{
language: null,
value: 'true'
}
]
firstMetadataValue(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter): string {
return 'True';
}
}))
})
});
bitstreamServiceIIIF = jasmine.createSpyObj('bitstreamService', {
findById: createSuccessfulRemoteDataObject$(bitstreamIIIFItem),
update: createSuccessfulRemoteDataObject$(bitstreamIIIFItem),
updateFormat: createSuccessfulRemoteDataObject$(bitstreamIIIFItem),
bitstreamService = jasmine.createSpyObj('bitstreamService', {
findById: createSuccessfulRemoteDataObject$(bitstream),
update: createSuccessfulRemoteDataObject$(bitstream),
updateFormat: createSuccessfulRemoteDataObject$(bitstream),
commitUpdates: {},
patch: {}
});
@@ -337,13 +330,14 @@ describe('EditBitstreamPageComponent', () => {
snapshot: {queryParams: {}}
}
},
{provide: BitstreamDataService, useValue: bitstreamServiceIIIF},
{provide: BitstreamDataService, useValue: bitstreamService},
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
ChangeDetectorRef
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(EditBitstreamPageComponent);
comp = fixture.componentInstance;
@@ -352,7 +346,7 @@ describe('EditBitstreamPageComponent', () => {
spyOn(router, 'navigate');
});
});
describe('on startup', () => {
let rawForm;
@@ -375,19 +369,16 @@ describe('EditBitstreamPageComponent', () => {
expect(comp.formLayout.iiifHeight.grid.host).toContain('col');
});
it('should fill in the iiif label', () => {
expect(rawForm.fileNamePrimaryContainer.fileName).toEqual('chapter one');
expect(rawForm.iiifLabelContainer.iiifLabel).toEqual('chapter one');
});
it('should fill in the iiif toc', () => {
expect(rawForm.fileNamePrimaryContainer.fileName).toEqual('chapter one');
expect(rawForm.iiifTocContainer.iiifToc).toEqual('chapter one');
});
it('should fill in the iiif width', () => {
expect(rawForm.fileNamePrimaryContainer.fileName).toEqual('2400');
expect(rawForm.iiifWidthContainer.iiifWidth).toEqual('2400');
});
it('should fill in the iiif height', () => {
expect(rawForm.fileNamePrimaryContainer.fileName).toEqual('2800');
expect(rawForm.iiifHeightContainer.iiifHeight).toEqual('2800');
});
});
}));
});