mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
Completed edit page and tests.
This commit is contained in:
@@ -30,8 +30,10 @@ 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;
|
||||
@@ -90,6 +92,9 @@ describe('EditBitstreamPageComponent', () => {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
describe('EditBitstreamPageComponent without IIIF fields', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
bitstream = Object.assign(new Bitstream(), {
|
||||
metadata: {
|
||||
'dc.description': [
|
||||
@@ -109,17 +114,12 @@ describe('EditBitstreamPageComponent', () => {
|
||||
},
|
||||
bundle: createSuccessfulRemoteDataObject$({
|
||||
item: createSuccessfulRemoteDataObject$(Object.assign(new Item(), {
|
||||
uuid: 'some-uuid'
|
||||
uuid: 'some-uuid',
|
||||
firstMetadataValue: () => '',
|
||||
}))
|
||||
})
|
||||
});
|
||||
bitstreamService = jasmine.createSpyObj('bitstreamService', {
|
||||
findById: createSuccessfulRemoteDataObject$(bitstream),
|
||||
update: createSuccessfulRemoteDataObject$(bitstream),
|
||||
updateFormat: createSuccessfulRemoteDataObject$(bitstream),
|
||||
commitUpdates: {},
|
||||
patch: {}
|
||||
});
|
||||
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: createSuccessfulRemoteDataObject$(createPaginatedList(allFormats))
|
||||
});
|
||||
@@ -130,14 +130,18 @@ describe('EditBitstreamPageComponent', () => {
|
||||
providers: [
|
||||
{provide: NotificationsService, useValue: notificationsService},
|
||||
{provide: DynamicFormService, useValue: formService},
|
||||
{ provide: ActivatedRoute, useValue: { data: observableOf({ bitstream: createSuccessfulRemoteDataObject(bitstream) }), snapshot: { queryParams: {} } } },
|
||||
{provide: ActivatedRoute,
|
||||
useValue: {
|
||||
data: observableOf({bitstream: createSuccessfulRemoteDataObject(bitstream)}),
|
||||
snapshot: {queryParams: {}}
|
||||
}
|
||||
},
|
||||
{provide: BitstreamDataService, useValue: bitstreamService},
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||
ChangeDetectorRef
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -170,6 +174,12 @@ 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', () => {
|
||||
@@ -242,4 +252,105 @@ describe('EditBitstreamPageComponent', () => {
|
||||
expect(router.navigate).toHaveBeenCalledWith([getEntityEditRoute(null, 'some-uuid'), 'bitstreams']);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('EditBitstreamPageComponent with IIIF', () => {
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
bitstreamService = jasmine.createSpyObj('bitstreamService', {
|
||||
findById: createSuccessfulRemoteDataObject$(bitstream),
|
||||
update: createSuccessfulRemoteDataObject$(bitstream),
|
||||
updateFormat: createSuccessfulRemoteDataObject$(bitstream),
|
||||
commitUpdates: {},
|
||||
patch: {}
|
||||
});
|
||||
bitstreamIIIFItem = Object.assign(new Bitstream(), {
|
||||
metadata: {
|
||||
'dc.description': [
|
||||
{
|
||||
value: 'Bitstream description'
|
||||
}
|
||||
],
|
||||
'dc.title': [
|
||||
{
|
||||
value: 'Bitstream title'
|
||||
}
|
||||
]
|
||||
},
|
||||
format: createSuccessfulRemoteDataObject$(selectedFormat),
|
||||
_links: {
|
||||
self: 'bitstream-selflink'
|
||||
},
|
||||
bundle: createSuccessfulRemoteDataObject$({
|
||||
item: createSuccessfulRemoteDataObject$(Object.assign(new Item(), {
|
||||
uuid: 'some-uuid',
|
||||
firstMetadataValue: () => 'true',
|
||||
metadata: {
|
||||
'dspace.iiif.enabled': [
|
||||
{
|
||||
language: null,
|
||||
value: 'true'
|
||||
}
|
||||
]
|
||||
}
|
||||
}))
|
||||
})
|
||||
});
|
||||
bitstreamServiceIIIF = jasmine.createSpyObj('bitstreamService', {
|
||||
findById: createSuccessfulRemoteDataObject$(bitstreamIIIFItem),
|
||||
update: createSuccessfulRemoteDataObject$(bitstreamIIIFItem),
|
||||
updateFormat: createSuccessfulRemoteDataObject$(bitstreamIIIFItem),
|
||||
commitUpdates: {},
|
||||
patch: {}
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule],
|
||||
declarations: [EditBitstreamPageComponent, FileSizePipe, VarDirective],
|
||||
providers: [
|
||||
{provide: NotificationsService, useValue: notificationsService},
|
||||
{provide: DynamicFormService, useValue: formService},
|
||||
{provide: ActivatedRoute,
|
||||
useValue: {
|
||||
data: observableOf({bitstream: createSuccessfulRemoteDataObject(bitstream)}),
|
||||
snapshot: {queryParams: {}}
|
||||
}
|
||||
},
|
||||
{provide: BitstreamDataService, useValue: bitstreamServiceIIIF},
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||
ChangeDetectorRef
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
}));
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EditBitstreamPageComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
router = TestBed.inject(Router);
|
||||
spyOn(router, 'navigate');
|
||||
});
|
||||
|
||||
});
|
||||
describe('on startup', () => {
|
||||
it('should set isIIIF to true', () => {
|
||||
expect(comp.isIIIF).toBeTrue();
|
||||
});
|
||||
it('should put the \"IIIF Label\" input to be shown', () => {
|
||||
expect(comp.formLayout.iiifLabel.grid.host).toContain('col');
|
||||
});
|
||||
it('should put the \"IIIF Toc\" input to be shown', () => {
|
||||
expect(comp.formLayout.iiifToc.grid.host).toContain('col');
|
||||
});
|
||||
it('should put the \"IIIF width\" input to be shown', () => {
|
||||
expect(comp.formLayout.iiifWidth.grid.host).toContain('col');
|
||||
});
|
||||
it('should put the \"IIIF Height\" input to be shown', () => {
|
||||
expect(comp.formLayout.iiifHeight.grid.host).toContain('col');
|
||||
});
|
||||
});
|
||||
|
||||
}));
|
||||
|
||||
});
|
||||
|
@@ -342,7 +342,10 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
entityType: string;
|
||||
|
||||
isIIIF: boolean;
|
||||
/**
|
||||
* Set to true when the parent item supports IIIF.
|
||||
*/
|
||||
isIIIF = false;
|
||||
|
||||
/**
|
||||
* Array to track all subscriptions and unsubscribe them onDestroy
|
||||
|
Reference in New Issue
Block a user