diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/frontend/users_select | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) | |
download | gitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/frontend/users_select')
-rw-r--r-- | spec/frontend/users_select/utils_spec.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/frontend/users_select/utils_spec.js b/spec/frontend/users_select/utils_spec.js new file mode 100644 index 00000000000..a09935d8a04 --- /dev/null +++ b/spec/frontend/users_select/utils_spec.js @@ -0,0 +1,33 @@ +import $ from 'jquery'; +import { getAjaxUsersSelectOptions, getAjaxUsersSelectParams } from '~/users_select/utils'; + +const options = { + fooBar: 'baz', + activeUserId: 1, +}; + +describe('getAjaxUsersSelectOptions', () => { + it('returns options built from select data attributes', () => { + const $select = $('<select />', { 'data-foo-bar': 'baz', 'data-user-id': 1 }); + + expect( + getAjaxUsersSelectOptions($select, { fooBar: 'fooBar', activeUserId: 'user-id' }), + ).toEqual(options); + }); +}); + +describe('getAjaxUsersSelectParams', () => { + it('returns query parameters built from provided options', () => { + expect( + getAjaxUsersSelectParams(options, { + foo_bar: 'fooBar', + active_user_id: 'activeUserId', + non_existent_key: 'nonExistentKey', + }), + ).toEqual({ + foo_bar: 'baz', + active_user_id: 1, + non_existent_key: null, + }); + }); +}); |