AAE-22947 Update form.model

This commit is contained in:
wiktord2000
2024-06-11 10:00:39 +02:00
parent 44e2911eaf
commit 1773500d75

View File

@@ -33,9 +33,7 @@ describe('FormModel', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
CoreTestingModule
]
imports: [CoreTestingModule]
});
formService = new FormService();
});
@@ -132,10 +130,7 @@ describe('FormModel', () => {
it('should parse tabs', () => {
const json = {
tabs: [
{ id: 'tab1' },
{ id: 'tab2' }
]
tabs: [{ id: 'tab1' }, { id: 'tab2' }]
};
const form = new FormModel(json);
@@ -199,10 +194,7 @@ describe('FormModel', () => {
it('should put fields into corresponding tabs', () => {
const json = {
tabs: [
{ id: 'tab1' },
{ id: 'tab2' }
],
tabs: [{ id: 'tab1' }, { id: 'tab2' }],
fields: [
{ id: 'field1', tab: 'tab1', type: FormFieldTypes.CONTAINER },
{ id: 'field2', tab: 'tab2', type: FormFieldTypes.CONTAINER },
@@ -227,9 +219,7 @@ describe('FormModel', () => {
it('should create standard form outcomes', () => {
const json = {
fields: [
{ id: 'container1' }
]
fields: [{ id: 'container1' }]
};
const form = new FormModel(json);
@@ -255,12 +245,8 @@ describe('FormModel', () => {
it('should use custom form outcomes', () => {
const json = {
fields: [
{ id: 'container1' }
],
outcomes: [
{ id: 'custom-1', name: 'custom 1' }
]
fields: [{ id: 'container1' }],
outcomes: [{ id: 'custom-1', name: 'custom 1' }]
};
const form = new FormModel(json);
@@ -276,9 +262,7 @@ describe('FormModel', () => {
it('should raise validation event when validating form', () => {
const form = new FormModel({}, null, false, formService);
formService.validateForm.subscribe((validateFormEvent) =>
expect(validateFormEvent).toBeTruthy()
);
formService.validateForm.subscribe((validateFormEvent) => expect(validateFormEvent).toBeTruthy());
form.validateForm();
});
@@ -286,9 +270,7 @@ describe('FormModel', () => {
const form = new FormModel({}, null, false, formService);
const field = jasmine.createSpyObj('FormFieldModel', ['validate']);
formService.validateFormField.subscribe((validateFormFieldEvent) =>
expect(validateFormFieldEvent).toBeTruthy()
);
formService.validateFormField.subscribe((validateFormFieldEvent) => expect(validateFormFieldEvent).toBeTruthy());
form.validateField(field);
});
@@ -587,8 +569,8 @@ describe('FormModel', () => {
const values = {
pfx_property_one: 'testValue',
pfx_property_two: true,
pfx_property_three: 'opt_1',
pfx_property_four: 'option_2',
pfx_property_three: { id: 'opt_1', name: 'Option 1' },
pfx_property_four: { id: 'option_2', name: 'Option: 2' },
pfx_property_five: 'orange',
pfx_property_six: 'other-value',
pfx_property_none: 'no_form_field'
@@ -604,7 +586,6 @@ describe('FormModel', () => {
expect(form.values['pfx_property_six']).toEqual('text-value');
expect(form.values['pfx_property_seven']).toBeNull();
expect(form.values['pfx_property_eight']).toBeNull();
});
});