Skip to content
Snippets Groups Projects
Commit 1bb3bb66 authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

64961: Test and naming fixes

parent f81de8ad
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ import { PaginatedList } from '../../core/data/paginated-list';
import { PageInfo } from '../../core/shared/page-info.model';
import { FileSizePipe } from '../../shared/utils/file-size-pipe';
import { RestResponse } from '../../core/cache/response.models';
import { VarDirective } from '../../shared/utils/var.directive';
const infoNotification: INotification = new Notification('id', NotificationType.Info, 'info');
const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning');
......@@ -95,9 +96,11 @@ describe('EditBitstreamPageComponent', () => {
format: observableOf(new RemoteData(false, false, true, null, selectedFormat))
});
bitstreamService = jasmine.createSpyObj('bitstreamService', {
findById: observableOf(new RemoteData(false, false, true, null, bitstream)),
update: observableOf(new RemoteData(false, false, true, null, bitstream)),
updateFormat: observableOf(new RestResponse(true, 200, 'OK')),
commitUpdates: {}
commitUpdates: {},
patch: {}
});
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
findAll: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), allFormats)))
......@@ -105,7 +108,7 @@ describe('EditBitstreamPageComponent', () => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), RouterTestingModule],
declarations: [EditBitstreamPageComponent, FileSizePipe],
declarations: [EditBitstreamPageComponent, FileSizePipe, VarDirective],
providers: [
{ provide: NotificationsService, useValue: notificationsService },
{ provide: DynamicFormService, useValue: formService },
......@@ -144,18 +147,18 @@ describe('EditBitstreamPageComponent', () => {
expect(rawForm.formatContainer.selectedFormat).toEqual(selectedFormat.id);
});
it('should put the \"Other Format\" input on invisible', () => {
expect(comp.formLayout.otherFormat.grid.host).toContain('invisible');
it('should put the \"New Format\" input on invisible', () => {
expect(comp.formLayout.newFormat.grid.host).toContain('invisible');
});
});
describe('when an unknown format is selected', () => {
beforeEach(() => {
comp.updateOtherFormatLayout(allFormats[0].id);
comp.updateNewFormatLayout(allFormats[0].id);
});
it('should remove the invisible class from the \"Other Format\" input', () => {
expect(comp.formLayout.otherFormat.grid.host).not.toContain('invisible');
it('should remove the invisible class from the \"New Format\" input', () => {
expect(comp.formLayout.newFormat.grid.host).not.toContain('invisible');
});
});
......@@ -172,10 +175,6 @@ describe('EditBitstreamPageComponent', () => {
it('should commit the updates', () => {
expect(bitstreamService.commitUpdates).toHaveBeenCalled();
});
it('should display a success notification', () => {
expect(notificationsService.success).toHaveBeenCalled();
});
});
describe('when selected format has changed', () => {
......@@ -200,10 +199,6 @@ describe('EditBitstreamPageComponent', () => {
it('should commit the updates', () => {
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
}
});
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
* @param selectedId
*/
updateOtherFormatLayout(selectedId: string) {
updateNewFormatLayout(selectedId: string) {
if (this.isUnknownFormat(selectedId)) {
this.formLayout.newFormat.grid.host = this.newFormatBaseLayout;
} else {
......@@ -427,7 +427,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
onChange(event) {
const model = event.model;
if (model.id === this.selectedFormatModel.id) {
this.updateOtherFormatLayout(model.value);
this.updateNewFormatLayout(model.value);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment