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