add submissionId to fieldparser, and refactor to create fieldparsers using DI

This commit is contained in:
Art Lowel
2019-11-05 15:53:41 +01:00
parent 82367ea778
commit d255838265
29 changed files with 352 additions and 167 deletions

View File

@@ -8,6 +8,7 @@ describe('SeriesFieldParser test suite', () => {
let field: FormFieldModel;
let initFormValues: any = {};
const submissionId = '1234';
const parserOptions: ParserOptions = {
readOnly: false,
submissionScope: 'testScopeUUID',
@@ -32,13 +33,13 @@ describe('SeriesFieldParser test suite', () => {
});
it('should init parser properly', () => {
const parser = new SeriesFieldParser(field, initFormValues, parserOptions);
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
expect(parser instanceof SeriesFieldParser).toBe(true);
});
it('should return a DynamicConcatModel object when repeatable option is false', () => {
const parser = new SeriesFieldParser(field, initFormValues, parserOptions);
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
const fieldModel = parser.parse();
@@ -46,7 +47,7 @@ describe('SeriesFieldParser test suite', () => {
});
it('should return a DynamicConcatModel object with the correct separator', () => {
const parser = new SeriesFieldParser(field, initFormValues, parserOptions);
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
const fieldModel = parser.parse();
@@ -59,7 +60,7 @@ describe('SeriesFieldParser test suite', () => {
};
const expectedValue = new FormFieldMetadataValueObject('test; series');
const parser = new SeriesFieldParser(field, initFormValues, parserOptions);
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
const fieldModel = parser.parse();