mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
64961: Test and naming fixes
This commit is contained in:
@@ -21,6 +21,7 @@ import { PaginatedList } from '../../core/data/paginated-list';
|
|||||||
import { PageInfo } from '../../core/shared/page-info.model';
|
import { PageInfo } from '../../core/shared/page-info.model';
|
||||||
import { FileSizePipe } from '../../shared/utils/file-size-pipe';
|
import { FileSizePipe } from '../../shared/utils/file-size-pipe';
|
||||||
import { RestResponse } from '../../core/cache/response.models';
|
import { RestResponse } from '../../core/cache/response.models';
|
||||||
|
import { VarDirective } from '../../shared/utils/var.directive';
|
||||||
|
|
||||||
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');
|
||||||
@@ -95,9 +96,11 @@ describe('EditBitstreamPageComponent', () => {
|
|||||||
format: observableOf(new RemoteData(false, false, true, null, selectedFormat))
|
format: observableOf(new RemoteData(false, false, true, null, selectedFormat))
|
||||||
});
|
});
|
||||||
bitstreamService = jasmine.createSpyObj('bitstreamService', {
|
bitstreamService = jasmine.createSpyObj('bitstreamService', {
|
||||||
|
findById: observableOf(new RemoteData(false, false, true, null, bitstream)),
|
||||||
update: observableOf(new RemoteData(false, false, true, null, bitstream)),
|
update: observableOf(new RemoteData(false, false, true, null, bitstream)),
|
||||||
updateFormat: observableOf(new RestResponse(true, 200, 'OK')),
|
updateFormat: observableOf(new RestResponse(true, 200, 'OK')),
|
||||||
commitUpdates: {}
|
commitUpdates: {},
|
||||||
|
patch: {}
|
||||||
});
|
});
|
||||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||||
findAll: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), allFormats)))
|
findAll: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), allFormats)))
|
||||||
@@ -105,7 +108,7 @@ describe('EditBitstreamPageComponent', () => {
|
|||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), RouterTestingModule],
|
imports: [TranslateModule.forRoot(), RouterTestingModule],
|
||||||
declarations: [EditBitstreamPageComponent, FileSizePipe],
|
declarations: [EditBitstreamPageComponent, FileSizePipe, VarDirective],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: NotificationsService, useValue: notificationsService },
|
{ provide: NotificationsService, useValue: notificationsService },
|
||||||
{ provide: DynamicFormService, useValue: formService },
|
{ provide: DynamicFormService, useValue: formService },
|
||||||
@@ -144,18 +147,18 @@ describe('EditBitstreamPageComponent', () => {
|
|||||||
expect(rawForm.formatContainer.selectedFormat).toEqual(selectedFormat.id);
|
expect(rawForm.formatContainer.selectedFormat).toEqual(selectedFormat.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should put the \"Other Format\" input on invisible', () => {
|
it('should put the \"New Format\" input on invisible', () => {
|
||||||
expect(comp.formLayout.otherFormat.grid.host).toContain('invisible');
|
expect(comp.formLayout.newFormat.grid.host).toContain('invisible');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when an unknown format is selected', () => {
|
describe('when an unknown format is selected', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
comp.updateOtherFormatLayout(allFormats[0].id);
|
comp.updateNewFormatLayout(allFormats[0].id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove the invisible class from the \"Other Format\" input', () => {
|
it('should remove the invisible class from the \"New Format\" input', () => {
|
||||||
expect(comp.formLayout.otherFormat.grid.host).not.toContain('invisible');
|
expect(comp.formLayout.newFormat.grid.host).not.toContain('invisible');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -172,10 +175,6 @@ describe('EditBitstreamPageComponent', () => {
|
|||||||
it('should commit the updates', () => {
|
it('should commit the updates', () => {
|
||||||
expect(bitstreamService.commitUpdates).toHaveBeenCalled();
|
expect(bitstreamService.commitUpdates).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a success notification', () => {
|
|
||||||
expect(notificationsService.success).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when selected format has changed', () => {
|
describe('when selected format has changed', () => {
|
||||||
@@ -200,10 +199,6 @@ describe('EditBitstreamPageComponent', () => {
|
|||||||
it('should commit the updates', () => {
|
it('should commit the updates', () => {
|
||||||
expect(bitstreamService.commitUpdates).toHaveBeenCalled();
|
expect(bitstreamService.commitUpdates).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a success notification', () => {
|
|
||||||
expect(notificationsService.success).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -362,7 +362,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
|||||||
selectedFormat: format.id
|
selectedFormat: format.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.updateOtherFormatLayout(format.id);
|
this.updateNewFormatLayout(format.id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
|||||||
* Update the layout of the "Other Format" input depending on the selected format
|
* Update the layout of the "Other Format" input depending on the selected format
|
||||||
* @param selectedId
|
* @param selectedId
|
||||||
*/
|
*/
|
||||||
updateOtherFormatLayout(selectedId: string) {
|
updateNewFormatLayout(selectedId: string) {
|
||||||
if (this.isUnknownFormat(selectedId)) {
|
if (this.isUnknownFormat(selectedId)) {
|
||||||
this.formLayout.newFormat.grid.host = this.newFormatBaseLayout;
|
this.formLayout.newFormat.grid.host = this.newFormatBaseLayout;
|
||||||
} else {
|
} else {
|
||||||
@@ -427,7 +427,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
|||||||
onChange(event) {
|
onChange(event) {
|
||||||
const model = event.model;
|
const model = event.model;
|
||||||
if (model.id === this.selectedFormatModel.id) {
|
if (model.id === this.selectedFormatModel.id) {
|
||||||
this.updateOtherFormatLayout(model.value);
|
this.updateNewFormatLayout(model.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user