1
0

Added form field parser factory to remove switch in row-parser.ts

This commit is contained in:
Giuseppe Digilio
2018-07-04 16:01:53 +02:00
parent f627c9443e
commit 8dd11c9a3c
27 changed files with 230 additions and 220 deletions

View File

@@ -2,6 +2,7 @@ import { FormFieldModel } from '../models/form-field.model';
import { NameFieldParser } from './name-field-parser';
import { DynamicConcatModel } from '../ds-dynamic-form-ui/models/ds-dynamic-concat.model';
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
import { ParserOptions } from './parser-options';
describe('NameFieldParser test suite', () => {
let field1: FormFieldModel;
@@ -9,7 +10,11 @@ describe('NameFieldParser test suite', () => {
let field3: FormFieldModel;
let initFormValues: any = {};
const readOnly = false;
const parserOptions: ParserOptions = {
readOnly: false,
submissionScope: 'testScopeUUID',
authorityUuid: null
};
beforeEach(() => {
field1 = {
@@ -64,13 +69,13 @@ describe('NameFieldParser test suite', () => {
});
it('should init parser properly', () => {
const parser = new NameFieldParser(field1, initFormValues, readOnly);
const parser = new NameFieldParser(field1, initFormValues, parserOptions);
expect(parser instanceof NameFieldParser).toBe(true);
});
it('should return a DynamicConcatModel object when repeatable option is false', () => {
const parser = new NameFieldParser(field2, initFormValues, readOnly);
const parser = new NameFieldParser(field2, initFormValues, parserOptions);
const fieldModel = parser.parse();
@@ -78,7 +83,7 @@ describe('NameFieldParser test suite', () => {
});
it('should return a DynamicConcatModel object with the correct separator', () => {
const parser = new NameFieldParser(field2, initFormValues, readOnly);
const parser = new NameFieldParser(field2, initFormValues, parserOptions);
const fieldModel = parser.parse();
@@ -91,7 +96,7 @@ describe('NameFieldParser test suite', () => {
};
const expectedValue = new FormFieldMetadataValueObject('test, name');
const parser = new NameFieldParser(field1, initFormValues, readOnly);
const parser = new NameFieldParser(field1, initFormValues, parserOptions);
const fieldModel = parser.parse();