summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKushal Pandya <kushalspandya@gmail.com>2019-08-15 21:49:25 +0530
committerKushal Pandya <kushalspandya@gmail.com>2019-08-22 17:58:44 +0530
commit6044b3ed1eb81cb55d1b978e76f1c1f3ee4e3a70 (patch)
tree67e337d3284590f79873e18e601a917d1b28c8f2 /spec
parente84f5a673e254c1e7084821a6d7c6ba919679aa5 (diff)
downloadgitlab-ce-6044b3ed1eb81cb55d1b978e76f1c1f3ee4e3a70.tar.gz
Add `searchBy` helper & `SidebarItemEpicsSelect`ce-6878-add-epic-select-dropdown
- Adds `searchBy` util in common utils - Adds placeholder `SidebarItemEpicsSelect`
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/lib/utils/common_utils_spec.js39
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);