diff options
author | Nick Thomas <nick@gitlab.com> | 2019-08-22 19:01:04 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-08-22 19:01:04 +0300 |
commit | d852112776a5d000a138cd49ad039ff0a87028d5 (patch) | |
tree | 684ac25be83882d86ca109c430eec70b8a9fbc2e /spec | |
parent | 03bf3271c1a80db87a1a0bf23b6472f2d939861f (diff) | |
parent | 6044b3ed1eb81cb55d1b978e76f1c1f3ee4e3a70 (diff) |
Merge branch 'ce-6878-add-epic-select-dropdown' into 'master'
Add `searchBy` helper & `SidebarItemEpicsSelect` placeholder component
See merge request gitlab-org/gitlab-ce!31859
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/lib/utils/common_utils_spec.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js b/spec/javascripts/lib/utils/common_utils_spec.js index 296ee85089f..85949f2ae86 100644 --- a/spec/javascripts/lib/utils/common_utils_spec.js +++ b/spec/javascripts/lib/utils/common_utils_spec.js @@ -895,6 +895,45 @@ describe('common_utils', () => { }); }); + describe('searchBy', () => { + const searchSpace = { + iid: 1, + reference: '&1', + title: 'Error omnis quos consequatur ullam a vitae sed omnis libero cupiditate.', + url: '/groups/gitlab-org/-/epics/1', + }; + + it('returns null when `query` or `searchSpace` params are empty/undefined', () => { + expect(commonUtils.searchBy('omnis', null)).toBeNull(); + expect(commonUtils.searchBy('', searchSpace)).toBeNull(); + expect(commonUtils.searchBy()).toBeNull(); + }); + + it('returns object with matching props based on `query` & `searchSpace` params', () => { + // String `omnis` is found only in `title` prop so return just that + expect(commonUtils.searchBy('omnis', searchSpace)).toEqual( + jasmine.objectContaining({ + title: searchSpace.title, + }), + ); + + // String `1` is found in both `iid` and `reference` props so return both + expect(commonUtils.searchBy('1', searchSpace)).toEqual( + jasmine.objectContaining({ + iid: searchSpace.iid, + reference: searchSpace.reference, + }), + ); + + // String `/epics/1` is found in `url` prop so return just that + expect(commonUtils.searchBy('/epics/1', searchSpace)).toEqual( + jasmine.objectContaining({ + url: searchSpace.url, + }), + ); + }); + }); + describe('isScopedLabel', () => { it('returns true when `::` is present in title', () => { expect(commonUtils.isScopedLabel({ title: 'foo::bar' })).toBe(true); |