diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2017-03-15 20:20:09 +0300 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2017-03-15 20:20:09 +0300 |
commit | 53d4cad1c9caadc8439e94a9f094f4de562c2583 (patch) | |
tree | 03970c69c883a8cd7e3baa1a457519938f13e5af /spec/javascripts | |
parent | ef447a6263e59b22e90a9629c2c5ae12f83d8bc5 (diff) | |
parent | 6e7e9e80e0a89c2c295ccaa4b8469b5ed33acd27 (diff) |
Merge branch '27174-filter-filters' into 'master'
prevent filtering Issues by multiple milestones, authors, or assignees
Closes #27174
See merge request !9406
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/filtered_search/dropdown_utils_spec.js | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/spec/javascripts/filtered_search/dropdown_utils_spec.js b/spec/javascripts/filtered_search/dropdown_utils_spec.js index 5c65903701b..e6538020896 100644 --- a/spec/javascripts/filtered_search/dropdown_utils_spec.js +++ b/spec/javascripts/filtered_search/dropdown_utils_spec.js @@ -126,7 +126,11 @@ require('~/filtered_search/filtered_search_dropdown_manager'); beforeEach(() => { setFixtures(` - <input type="text" id="test" /> + <ul class="tokens-container"> + <li class="input-token"> + <input class="filtered-search" type="text" id="test" /> + </li> + </ul> `); input = document.getElementById('test'); @@ -142,7 +146,7 @@ require('~/filtered_search/filtered_search_dropdown_manager'); input.value = 'o'; updatedItem = gl.DropdownUtils.filterHint(input, { hint: 'label', - }, 'o'); + }); expect(updatedItem.droplab_hidden).toBe(true); }); @@ -150,6 +154,29 @@ require('~/filtered_search/filtered_search_dropdown_manager'); const updatedItem = gl.DropdownUtils.filterHint(input, {}, ''); expect(updatedItem.droplab_hidden).toBe(false); }); + + it('should allow multiple if item.type is array', () => { + input.value = 'label:~first la'; + const updatedItem = gl.DropdownUtils.filterHint(input, { + hint: 'label', + type: 'array', + }); + expect(updatedItem.droplab_hidden).toBe(false); + }); + + it('should prevent multiple if item.type is not array', () => { + input.value = 'milestone:~first mile'; + let updatedItem = gl.DropdownUtils.filterHint(input, { + hint: 'milestone', + }); + expect(updatedItem.droplab_hidden).toBe(true); + + updatedItem = gl.DropdownUtils.filterHint(input, { + hint: 'milestone', + type: 'string', + }); + expect(updatedItem.droplab_hidden).toBe(true); + }); }); describe('setDataValueIfSelected', () => { |