diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-12 12:07:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-12 12:07:48 +0300 |
commit | fc53ce8e6ca67bf217470179a1ea6cf139bcffad (patch) | |
tree | 3721386728719a7779d1cd627281e9a28cc40c4a /spec/javascripts/lib | |
parent | 8e22ef10e4f9c6d1ef2411aa26ddd0658e2f1461 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts/lib')
-rw-r--r-- | spec/javascripts/lib/utils/common_utils_spec.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js b/spec/javascripts/lib/utils/common_utils_spec.js index 484133c9ac4..e471be608c8 100644 --- a/spec/javascripts/lib/utils/common_utils_spec.js +++ b/spec/javascripts/lib/utils/common_utils_spec.js @@ -721,6 +721,28 @@ describe('common_utils', () => { }); }); + describe('convertObjectPropsToSnakeCase', () => { + it('converts each object key to snake case', () => { + const obj = { + some: 'some', + 'cool object': 'cool object', + likeThisLongOne: 'likeThisLongOne', + }; + + expect(commonUtils.convertObjectPropsToSnakeCase(obj)).toEqual({ + some: 'some', + cool_object: 'cool object', + like_this_long_one: 'likeThisLongOne', + }); + }); + + it('returns an empty object if there are no keys', () => { + ['', {}, [], null].forEach(badObj => { + expect(commonUtils.convertObjectPropsToSnakeCase(badObj)).toEqual({}); + }); + }); + }); + describe('with options', () => { const objWithoutChildren = { project_name: 'GitLab CE', |