mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Fix tests to include translationservice dependency
This commit is contained in:
@@ -51,6 +51,8 @@ import { FormRowModel } from '../../../core/config/models/config-submission-form
|
|||||||
import {ConfigurationDataService} from '../../../core/data/configuration-data.service';
|
import {ConfigurationDataService} from '../../../core/data/configuration-data.service';
|
||||||
import {createSuccessfulRemoteDataObject$} from '../../remote-data.utils';
|
import {createSuccessfulRemoteDataObject$} from '../../remote-data.utils';
|
||||||
import {ConfigurationProperty} from '../../../core/shared/configuration-property.model';
|
import {ConfigurationProperty} from '../../../core/shared/configuration-property.model';
|
||||||
|
import { getMockTranslateService } from '../../mocks/translate.service.mock';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
describe('FormBuilderService test suite', () => {
|
describe('FormBuilderService test suite', () => {
|
||||||
|
|
||||||
@@ -81,6 +83,7 @@ describe('FormBuilderService test suite', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
configSpy = createConfigSuccessSpy(typeFieldTestValue);
|
configSpy = createConfigSuccessSpy(typeFieldTestValue);
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [ReactiveFormsModule],
|
imports: [ReactiveFormsModule],
|
||||||
providers: [
|
providers: [
|
||||||
@@ -88,7 +91,8 @@ describe('FormBuilderService test suite', () => {
|
|||||||
{ provide: DynamicFormValidationService, useValue: {} },
|
{ provide: DynamicFormValidationService, useValue: {} },
|
||||||
{ provide: NG_VALIDATORS, useValue: testValidator, multi: true },
|
{ provide: NG_VALIDATORS, useValue: testValidator, multi: true },
|
||||||
{ provide: NG_ASYNC_VALIDATORS, useValue: testAsyncValidator, multi: true },
|
{ provide: NG_ASYNC_VALIDATORS, useValue: testAsyncValidator, multi: true },
|
||||||
{ provide: ConfigurationDataService, useValue: configSpy }
|
{ provide: ConfigurationDataService, useValue: configSpy },
|
||||||
|
{ provide: TranslateService, useValue: translateService },
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -3,10 +3,14 @@ import { DateFieldParser } from './date-field-parser';
|
|||||||
import { DynamicDsDatePickerModel } from '../ds-dynamic-form-ui/models/date-picker/date-picker.model';
|
import { DynamicDsDatePickerModel } from '../ds-dynamic-form-ui/models/date-picker/date-picker.model';
|
||||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe('DateFieldParser test suite', () => {
|
describe('DateFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -37,13 +41,13 @@ describe('DateFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof DateFieldParser).toBe(true);
|
expect(parser instanceof DateFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicDsDatePickerModel object when repeatable option is false', () => {
|
it('should return a DynamicDsDatePickerModel object when repeatable option is false', () => {
|
||||||
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -56,7 +60,7 @@ describe('DateFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = '1983-11-18';
|
const expectedValue = '1983-11-18';
|
||||||
|
|
||||||
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -2,10 +2,12 @@ import { FormFieldModel } from '../models/form-field.model';
|
|||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
import { DisabledFieldParser } from './disabled-field-parser';
|
import { DisabledFieldParser } from './disabled-field-parser';
|
||||||
import { DynamicDisabledModel } from '../ds-dynamic-form-ui/models/disabled/dynamic-disabled.model';
|
import { DynamicDisabledModel } from '../ds-dynamic-form-ui/models/disabled/dynamic-disabled.model';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('DisabledFieldParser test suite', () => {
|
describe('DisabledFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -35,13 +37,13 @@ describe('DisabledFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof DisabledFieldParser).toBe(true);
|
expect(parser instanceof DisabledFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicDisabledModel object when repeatable option is false', () => {
|
it('should return a DynamicDisabledModel object when repeatable option is false', () => {
|
||||||
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -56,7 +58,7 @@ describe('DisabledFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = 'test description';
|
const expectedValue = 'test description';
|
||||||
|
|
||||||
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
expect(fieldModel.value.value).toEqual(expectedValue);
|
expect(fieldModel.value.value).toEqual(expectedValue);
|
||||||
|
@@ -2,9 +2,11 @@ import { FormFieldModel } from '../models/form-field.model';
|
|||||||
import { DropdownFieldParser } from './dropdown-field-parser';
|
import { DropdownFieldParser } from './dropdown-field-parser';
|
||||||
import { DynamicScrollableDropdownModel } from '../ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
|
import { DynamicScrollableDropdownModel } from '../ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('DropdownFieldParser test suite', () => {
|
describe('DropdownFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const initFormValues = {};
|
const initFormValues = {};
|
||||||
@@ -37,13 +39,13 @@ describe('DropdownFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof DropdownFieldParser).toBe(true);
|
expect(parser instanceof DropdownFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicScrollableDropdownModel object when repeatable option is false', () => {
|
it('should return a DynamicScrollableDropdownModel object when repeatable option is false', () => {
|
||||||
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ describe('DropdownFieldParser test suite', () => {
|
|||||||
|
|
||||||
it('should throw when authority is not passed', () => {
|
it('should throw when authority is not passed', () => {
|
||||||
field.selectableMetadata[0].controlledVocabulary = null;
|
field.selectableMetadata[0].controlledVocabulary = null;
|
||||||
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(() => parser.parse())
|
expect(() => parser.parse())
|
||||||
.toThrow();
|
.toThrow();
|
||||||
|
@@ -4,10 +4,12 @@ import { ListFieldParser } from './list-field-parser';
|
|||||||
import { DynamicListCheckboxGroupModel } from '../ds-dynamic-form-ui/models/list/dynamic-list-checkbox-group.model';
|
import { DynamicListCheckboxGroupModel } from '../ds-dynamic-form-ui/models/list/dynamic-list-checkbox-group.model';
|
||||||
import { DynamicListRadioGroupModel } from '../ds-dynamic-form-ui/models/list/dynamic-list-radio-group.model';
|
import { DynamicListRadioGroupModel } from '../ds-dynamic-form-ui/models/list/dynamic-list-radio-group.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('ListFieldParser test suite', () => {
|
describe('ListFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues = {};
|
let initFormValues = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -39,13 +41,13 @@ describe('ListFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof ListFieldParser).toBe(true);
|
expect(parser instanceof ListFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicListCheckboxGroupModel object when repeatable option is true', () => {
|
it('should return a DynamicListCheckboxGroupModel object when repeatable option is true', () => {
|
||||||
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ describe('ListFieldParser test suite', () => {
|
|||||||
|
|
||||||
it('should return a DynamicListRadioGroupModel object when repeatable option is false', () => {
|
it('should return a DynamicListRadioGroupModel object when repeatable option is false', () => {
|
||||||
field.repeatable = false;
|
field.repeatable = false;
|
||||||
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -67,7 +69,7 @@ describe('ListFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = [new FormFieldMetadataValueObject('test type')];
|
const expectedValue = [new FormFieldMetadataValueObject('test type')];
|
||||||
|
|
||||||
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@ import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu
|
|||||||
import { LookupFieldParser } from './lookup-field-parser';
|
import { LookupFieldParser } from './lookup-field-parser';
|
||||||
import { DynamicLookupModel } from '../ds-dynamic-form-ui/models/lookup/dynamic-lookup.model';
|
import { DynamicLookupModel } from '../ds-dynamic-form-ui/models/lookup/dynamic-lookup.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('LookupFieldParser test suite', () => {
|
describe('LookupFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues = {};
|
let initFormValues = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -38,13 +40,13 @@ describe('LookupFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof LookupFieldParser).toBe(true);
|
expect(parser instanceof LookupFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicLookupModel object when repeatable option is false', () => {
|
it('should return a DynamicLookupModel object when repeatable option is false', () => {
|
||||||
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ describe('LookupFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = new FormFieldMetadataValueObject('test journal');
|
const expectedValue = new FormFieldMetadataValueObject('test journal');
|
||||||
|
|
||||||
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@ import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu
|
|||||||
import { LookupNameFieldParser } from './lookup-name-field-parser';
|
import { LookupNameFieldParser } from './lookup-name-field-parser';
|
||||||
import { DynamicLookupNameModel } from '../ds-dynamic-form-ui/models/lookup/dynamic-lookup-name.model';
|
import { DynamicLookupNameModel } from '../ds-dynamic-form-ui/models/lookup/dynamic-lookup-name.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('LookupNameFieldParser test suite', () => {
|
describe('LookupNameFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues = {};
|
let initFormValues = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -38,13 +40,13 @@ describe('LookupNameFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof LookupNameFieldParser).toBe(true);
|
expect(parser instanceof LookupNameFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicLookupNameModel object when repeatable option is false', () => {
|
it('should return a DynamicLookupNameModel object when repeatable option is false', () => {
|
||||||
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ describe('LookupNameFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = new FormFieldMetadataValueObject('test author');
|
const expectedValue = new FormFieldMetadataValueObject('test author');
|
||||||
|
|
||||||
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -3,12 +3,14 @@ import { NameFieldParser } from './name-field-parser';
|
|||||||
import { DynamicConcatModel } from '../ds-dynamic-form-ui/models/ds-dynamic-concat.model';
|
import { DynamicConcatModel } from '../ds-dynamic-form-ui/models/ds-dynamic-concat.model';
|
||||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('NameFieldParser test suite', () => {
|
describe('NameFieldParser test suite', () => {
|
||||||
let field1: FormFieldModel;
|
let field1: FormFieldModel;
|
||||||
let field2: FormFieldModel;
|
let field2: FormFieldModel;
|
||||||
let field3: FormFieldModel;
|
let field3: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -71,13 +73,13 @@ describe('NameFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new NameFieldParser(submissionId, field1, initFormValues, parserOptions);
|
const parser = new NameFieldParser(submissionId, field1, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof NameFieldParser).toBe(true);
|
expect(parser instanceof NameFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicConcatModel object when repeatable option is false', () => {
|
it('should return a DynamicConcatModel object when repeatable option is false', () => {
|
||||||
const parser = new NameFieldParser(submissionId, field2, initFormValues, parserOptions);
|
const parser = new NameFieldParser(submissionId, field2, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -85,7 +87,7 @@ describe('NameFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicConcatModel object with the correct separator', () => {
|
it('should return a DynamicConcatModel object with the correct separator', () => {
|
||||||
const parser = new NameFieldParser(submissionId, field2, initFormValues, parserOptions);
|
const parser = new NameFieldParser(submissionId, field2, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -98,7 +100,7 @@ describe('NameFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = new FormFieldMetadataValueObject('test, name', undefined, undefined, 'test');
|
const expectedValue = new FormFieldMetadataValueObject('test, name', undefined, undefined, 'test');
|
||||||
|
|
||||||
const parser = new NameFieldParser(submissionId, field1, initFormValues, parserOptions);
|
const parser = new NameFieldParser(submissionId, field1, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -5,11 +5,13 @@ import { DynamicOneboxModel } from '../ds-dynamic-form-ui/models/onebox/dynamic-
|
|||||||
import { DsDynamicInputModel } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
|
import { DsDynamicInputModel } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
import { FieldParser } from './field-parser';
|
import { FieldParser } from './field-parser';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('OneboxFieldParser test suite', () => {
|
describe('OneboxFieldParser test suite', () => {
|
||||||
let field1: FormFieldModel;
|
let field1: FormFieldModel;
|
||||||
let field2: FormFieldModel;
|
let field2: FormFieldModel;
|
||||||
let field3: FormFieldModel;
|
let field3: FormFieldModel;
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const initFormValues = {};
|
const initFormValues = {};
|
||||||
@@ -73,13 +75,13 @@ describe('OneboxFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new OneboxFieldParser(submissionId, field1, initFormValues, parserOptions);
|
const parser = new OneboxFieldParser(submissionId, field1, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof OneboxFieldParser).toBe(true);
|
expect(parser instanceof OneboxFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicQualdropModel object when selectableMetadata is multiple', () => {
|
it('should return a DynamicQualdropModel object when selectableMetadata is multiple', () => {
|
||||||
const parser = new OneboxFieldParser(submissionId, field2, initFormValues, parserOptions);
|
const parser = new OneboxFieldParser(submissionId, field2, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -87,7 +89,7 @@ describe('OneboxFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DsDynamicInputModel object when selectableMetadata is not multiple', () => {
|
it('should return a DsDynamicInputModel object when selectableMetadata is not multiple', () => {
|
||||||
const parser = new OneboxFieldParser(submissionId, field3, initFormValues, parserOptions);
|
const parser = new OneboxFieldParser(submissionId, field3, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -95,7 +97,7 @@ describe('OneboxFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicOneboxModel object when selectableMetadata has authority', () => {
|
it('should return a DynamicOneboxModel object when selectableMetadata has authority', () => {
|
||||||
const parser = new OneboxFieldParser(submissionId, field1, initFormValues, parserOptions);
|
const parser = new OneboxFieldParser(submissionId, field1, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -124,7 +126,7 @@ describe('OneboxFieldParser test suite', () => {
|
|||||||
languageCodes: []
|
languageCodes: []
|
||||||
} as FormFieldModel;
|
} as FormFieldModel;
|
||||||
|
|
||||||
parser = new OneboxFieldParser(submissionId, regexField, initFormValues, parserOptions);
|
parser = new OneboxFieldParser(submissionId, regexField, initFormValues, parserOptions, translateService);
|
||||||
fieldModel = parser.parse();
|
fieldModel = parser.parse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@ import { RelationGroupFieldParser } from './relation-group-field-parser';
|
|||||||
import { DynamicRelationGroupModel } from '../ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model';
|
import { DynamicRelationGroupModel } from '../ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model';
|
||||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('RelationGroupFieldParser test suite', () => {
|
describe('RelationGroupFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues = {};
|
let initFormValues = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -73,13 +75,13 @@ describe('RelationGroupFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof RelationGroupFieldParser).toBe(true);
|
expect(parser instanceof RelationGroupFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicRelationGroupModel object', () => {
|
it('should return a DynamicRelationGroupModel object', () => {
|
||||||
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -88,7 +90,7 @@ describe('RelationGroupFieldParser test suite', () => {
|
|||||||
|
|
||||||
it('should throw when rows configuration is empty', () => {
|
it('should throw when rows configuration is empty', () => {
|
||||||
field.rows = null;
|
field.rows = null;
|
||||||
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(() => parser.parse())
|
expect(() => parser.parse())
|
||||||
.toThrow();
|
.toThrow();
|
||||||
@@ -99,7 +101,7 @@ describe('RelationGroupFieldParser test suite', () => {
|
|||||||
author: [new FormFieldMetadataValueObject('test author')],
|
author: [new FormFieldMetadataValueObject('test author')],
|
||||||
affiliation: [new FormFieldMetadataValueObject('test affiliation')]
|
affiliation: [new FormFieldMetadataValueObject('test affiliation')]
|
||||||
};
|
};
|
||||||
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
const expectedValue = [{
|
const expectedValue = [{
|
||||||
|
@@ -3,6 +3,10 @@ import { RowParser } from './row-parser';
|
|||||||
import { DynamicRowGroupModel } from '../ds-dynamic-form-ui/models/ds-dynamic-row-group-model';
|
import { DynamicRowGroupModel } from '../ds-dynamic-form-ui/models/ds-dynamic-row-group-model';
|
||||||
import { DynamicRowArrayModel } from '../ds-dynamic-form-ui/models/ds-dynamic-row-array-model';
|
import { DynamicRowArrayModel } from '../ds-dynamic-form-ui/models/ds-dynamic-row-array-model';
|
||||||
import { FormRowModel } from '../../../../core/config/models/config-submission-form.model';
|
import { FormRowModel } from '../../../../core/config/models/config-submission-form.model';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { Injector } from '@angular/core';
|
||||||
|
|
||||||
describe('RowParser test suite', () => {
|
describe('RowParser test suite', () => {
|
||||||
|
|
||||||
@@ -16,6 +20,7 @@ describe('RowParser test suite', () => {
|
|||||||
let row8: FormRowModel;
|
let row8: FormRowModel;
|
||||||
let row9: FormRowModel;
|
let row9: FormRowModel;
|
||||||
let row10: FormRowModel;
|
let row10: FormRowModel;
|
||||||
|
let injector: Injector;
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const scopeUUID = 'testScopeUUID';
|
const scopeUUID = 'testScopeUUID';
|
||||||
@@ -25,6 +30,12 @@ describe('RowParser test suite', () => {
|
|||||||
const typeField = 'dc_type';
|
const typeField = 'dc_type';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
injector = Injector.create({
|
||||||
|
providers: [
|
||||||
|
{ provide: TranslateService, useValue: translateService },
|
||||||
|
],
|
||||||
|
});
|
||||||
row1 = {
|
row1 = {
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -330,14 +341,14 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
expect(parser instanceof RowParser).toBe(true);
|
expect(parser instanceof RowParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parse', () => {
|
describe('parse', () => {
|
||||||
it('should return a DynamicRowGroupModel object', () => {
|
it('should return a DynamicRowGroupModel object', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -345,7 +356,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a row with three fields', () => {
|
it('should return a row with three fields', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -353,7 +364,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicRowArrayModel object', () => {
|
it('should return a DynamicRowArrayModel object', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row2, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row2, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -361,7 +372,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a row that contains only scoped fields', () => {
|
it('should return a row that contains only scoped fields', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row3, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row3, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -369,7 +380,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a dropdown combo field', () => {
|
it('should be able to parse a dropdown combo field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row4, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row4, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -377,7 +388,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a lookup-name field', () => {
|
it('should be able to parse a lookup-name field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row5, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row5, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -385,7 +396,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a list field', () => {
|
it('should be able to parse a list field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row6, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row6, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -393,7 +404,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a date field', () => {
|
it('should be able to parse a date field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row7, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row7, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -401,7 +412,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a tag field', () => {
|
it('should be able to parse a tag field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row8, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row8, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -409,7 +420,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a textarea field', () => {
|
it('should be able to parse a textarea field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row9, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row9, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -417,7 +428,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a group field', () => {
|
it('should be able to parse a group field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row10, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row10, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@ import { DynamicConcatModel } from '../ds-dynamic-form-ui/models/ds-dynamic-conc
|
|||||||
import { SeriesFieldParser } from './series-field-parser';
|
import { SeriesFieldParser } from './series-field-parser';
|
||||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('SeriesFieldParser test suite', () => {
|
describe('SeriesFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -34,13 +36,13 @@ describe('SeriesFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof SeriesFieldParser).toBe(true);
|
expect(parser instanceof SeriesFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicConcatModel object when repeatable option is false', () => {
|
it('should return a DynamicConcatModel object when repeatable option is false', () => {
|
||||||
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ describe('SeriesFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicConcatModel object with the correct separator', () => {
|
it('should return a DynamicConcatModel object with the correct separator', () => {
|
||||||
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -61,7 +63,7 @@ describe('SeriesFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = new FormFieldMetadataValueObject('test; series', undefined, undefined, 'test');
|
const expectedValue = new FormFieldMetadataValueObject('test; series', undefined, undefined, 'test');
|
||||||
|
|
||||||
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@ import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu
|
|||||||
import { TagFieldParser } from './tag-field-parser';
|
import { TagFieldParser } from './tag-field-parser';
|
||||||
import { DynamicTagModel } from '../ds-dynamic-form-ui/models/tag/dynamic-tag.model';
|
import { DynamicTagModel } from '../ds-dynamic-form-ui/models/tag/dynamic-tag.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('TagFieldParser test suite', () => {
|
describe('TagFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -38,13 +40,13 @@ describe('TagFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof TagFieldParser).toBe(true);
|
expect(parser instanceof TagFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicTagModel object when repeatable option is false', () => {
|
it('should return a DynamicTagModel object when repeatable option is false', () => {
|
||||||
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -59,7 +61,7 @@ describe('TagFieldParser test suite', () => {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@ import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu
|
|||||||
import { TextareaFieldParser } from './textarea-field-parser';
|
import { TextareaFieldParser } from './textarea-field-parser';
|
||||||
import { DsDynamicTextAreaModel } from '../ds-dynamic-form-ui/models/ds-dynamic-textarea.model';
|
import { DsDynamicTextAreaModel } from '../ds-dynamic-form-ui/models/ds-dynamic-textarea.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('TextareaFieldParser test suite', () => {
|
describe('TextareaFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -36,13 +38,13 @@ describe('TextareaFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof TextareaFieldParser).toBe(true);
|
expect(parser instanceof TextareaFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DsDynamicTextAreaModel object when repeatable option is false', () => {
|
it('should return a DsDynamicTextAreaModel object when repeatable option is false', () => {
|
||||||
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ describe('TextareaFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = 'test description';
|
const expectedValue = 'test description';
|
||||||
|
|
||||||
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user