mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Added form field parser factory to remove switch in row-parser.ts
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import { FormFieldModel } from '../models/form-field.model';
|
||||
import { DropdownFieldParser } from './dropdown-field-parser';
|
||||
import { DynamicScrollableDropdownModel } from '../ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
|
||||
import { ParserOptions } from './parser-options';
|
||||
|
||||
describe('DropdownFieldParser test suite', () => {
|
||||
let field: FormFieldModel;
|
||||
|
||||
const authorityUuid = 'testScopeUUID';
|
||||
const initFormValues = {};
|
||||
const readOnly = false;
|
||||
const parserOptions: ParserOptions = {
|
||||
readOnly: false,
|
||||
submissionScope: 'testScopeUUID',
|
||||
authorityUuid: null
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
field = {
|
||||
@@ -31,13 +35,13 @@ describe('DropdownFieldParser test suite', () => {
|
||||
});
|
||||
|
||||
it('should init parser properly', () => {
|
||||
const parser = new DropdownFieldParser(field, initFormValues, readOnly, authorityUuid);
|
||||
const parser = new DropdownFieldParser(field, initFormValues, parserOptions);
|
||||
|
||||
expect(parser instanceof DropdownFieldParser).toBe(true);
|
||||
});
|
||||
|
||||
it('should return a DynamicScrollableDropdownModel object when repeatable option is false', () => {
|
||||
const parser = new DropdownFieldParser(field, initFormValues, readOnly, authorityUuid);
|
||||
const parser = new DropdownFieldParser(field, initFormValues, parserOptions);
|
||||
|
||||
const fieldModel = parser.parse();
|
||||
|
||||
@@ -46,7 +50,7 @@ describe('DropdownFieldParser test suite', () => {
|
||||
|
||||
it('should throw when authority is not passed', () => {
|
||||
field.selectableMetadata[0].authority = null;
|
||||
const parser = new DropdownFieldParser(field, initFormValues, readOnly, authorityUuid);
|
||||
const parser = new DropdownFieldParser(field, initFormValues, parserOptions);
|
||||
|
||||
expect(() => parser.parse())
|
||||
.toThrow();
|
||||
|
Reference in New Issue
Block a user