Commit 1fc10388 authored by Samantha Ming's avatar Samantha Ming

Refactor validation spec by caching object

Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/330691
parent 7368e2a6
...@@ -240,14 +240,16 @@ describe('initForm', () => { ...@@ -240,14 +240,16 @@ describe('initForm', () => {
}, },
}; };
const EXPECTED_FIELDS = {
name: { value: 'lorem', required: true, state: null, feedback: null },
description: { value: 'ipsum', required: false, state: true, feedback: null },
};
it('returns form object', () => { it('returns form object', () => {
expect(initForm(MOCK_FORM)).toMatchObject({ expect(initForm(MOCK_FORM)).toMatchObject({
state: false, state: false,
showValidation: false, showValidation: false,
fields: { fields: EXPECTED_FIELDS,
name: { value: 'lorem', required: true, state: null, feedback: null },
description: { value: 'ipsum', required: false, state: true, feedback: null },
},
}); });
}); });
...@@ -266,10 +268,7 @@ describe('initForm', () => { ...@@ -266,10 +268,7 @@ describe('initForm', () => {
expect(initForm(form)).toMatchObject({ expect(initForm(form)).toMatchObject({
state: false, state: false,
showValidation: false, showValidation: false,
fields: { fields: EXPECTED_FIELDS,
name: { value: 'lorem', required: true, state: null, feedback: null },
description: { value: 'ipsum', required: false, state: true, feedback: null },
},
...customFormObject, ...customFormObject,
}); });
}); });
...@@ -284,10 +283,7 @@ describe('initForm', () => { ...@@ -284,10 +283,7 @@ describe('initForm', () => {
expect(initForm(form)).toMatchObject({ expect(initForm(form)).toMatchObject({
state: true, state: true,
showValidation: true, showValidation: true,
fields: { fields: EXPECTED_FIELDS,
name: { value: 'lorem', required: true, state: null, feedback: null },
description: { value: 'ipsum', required: false, state: true, feedback: null },
},
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment