diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/frontend/alerts_settings/utils/mapping_transformations_spec.js | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/frontend/alerts_settings/utils/mapping_transformations_spec.js')
-rw-r--r-- | spec/frontend/alerts_settings/utils/mapping_transformations_spec.js | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/spec/frontend/alerts_settings/utils/mapping_transformations_spec.js b/spec/frontend/alerts_settings/utils/mapping_transformations_spec.js index 62b95c6078b..8a0800457c6 100644 --- a/spec/frontend/alerts_settings/utils/mapping_transformations_spec.js +++ b/spec/frontend/alerts_settings/utils/mapping_transformations_spec.js @@ -1,4 +1,8 @@ -import { getMappingData, transformForSave } from '~/alerts_settings/utils/mapping_transformations'; +import { + getMappingData, + setFieldsLabels, + transformForSave, +} from '~/alerts_settings/utils/mapping_transformations'; import alertFields from '../mocks/alert_fields.json'; import parsedMapping from '../mocks/parsed_mapping.json'; @@ -64,4 +68,33 @@ describe('Mapping Transformation Utilities', () => { expect(result).toEqual([]); }); }); + + describe('setFieldsLabels', () => { + const nonNestedFields = [{ label: 'title' }]; + const nonNestedFieldsResult = { displayLabel: 'Title', tooltip: undefined }; + + const nestedFields = [ + { + label: 'field/subfield', + }, + ]; + const nestedFieldsResult = { displayLabel: '...Subfield', tooltip: 'field.subfield' }; + + const nestedArrayFields = [ + { + label: 'fields[1]/subfield', + }, + ]; + + const nestedArrayFieldsResult = { displayLabel: '...Subfield', tooltip: 'fields[1].subfield' }; + + it.each` + type | fields | result + ${'not nested field'} | ${nonNestedFields} | ${nonNestedFieldsResult} + ${'nested field'} | ${nestedFields} | ${nestedFieldsResult} + ${'nested inside array'} | ${nestedArrayFields} | ${nestedArrayFieldsResult} + `('adds correct displayLabel and tooltip for $type', ({ fields, result }) => { + expect(setFieldsLabels(fields)[0]).toMatchObject(result); + }); + }); }); |