summaryrefslogtreecommitdiff
path: root/spec/javascripts/filtered_search/dropdown_utils_spec.js.es6
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/filtered_search/dropdown_utils_spec.js.es6')
-rw-r--r--spec/javascripts/filtered_search/dropdown_utils_spec.js.es641
1 files changed, 34 insertions, 7 deletions
diff --git a/spec/javascripts/filtered_search/dropdown_utils_spec.js.es6 b/spec/javascripts/filtered_search/dropdown_utils_spec.js.es6
index 96f33427213..074a46349ab 100644
--- a/spec/javascripts/filtered_search/dropdown_utils_spec.js.es6
+++ b/spec/javascripts/filtered_search/dropdown_utils_spec.js.es6
@@ -31,41 +31,68 @@ require('~/filtered_search/filtered_search_dropdown_manager');
});
describe('filterWithSymbol', () => {
+ let input;
const item = {
title: '@root',
};
+ beforeEach(() => {
+ setFixtures(`
+ <input type="text" id="test" />
+ `);
+
+ input = document.getElementById('test');
+ });
+
it('should filter without symbol', () => {
- const updatedItem = gl.DropdownUtils.filterWithSymbol('@', item, ':roo');
+ input.value = ':roo';
+
+ const updatedItem = gl.DropdownUtils.filterWithSymbol('@', input, item);
expect(updatedItem.droplab_hidden).toBe(false);
});
it('should filter with symbol', () => {
- const updatedItem = gl.DropdownUtils.filterWithSymbol('@', item, ':@roo');
+ input.value = '@roo';
+
+ const updatedItem = gl.DropdownUtils.filterWithSymbol('@', input, item);
expect(updatedItem.droplab_hidden).toBe(false);
});
it('should filter with colon', () => {
- const updatedItem = gl.DropdownUtils.filterWithSymbol('@', item, ':');
+ input.value = 'roo';
+
+ const updatedItem = gl.DropdownUtils.filterWithSymbol('@', input, item);
expect(updatedItem.droplab_hidden).toBe(false);
});
});
describe('filterHint', () => {
+ let input;
+
+ beforeEach(() => {
+ setFixtures(`
+ <input type="text" id="test" />
+ `);
+
+ input = document.getElementById('test');
+ });
+
it('should filter', () => {
- let updatedItem = gl.DropdownUtils.filterHint({
+ input.value = 'l';
+ let updatedItem = gl.DropdownUtils.filterHint(input, {
hint: 'label',
- }, 'l');
+ });
expect(updatedItem.droplab_hidden).toBe(false);
- updatedItem = gl.DropdownUtils.filterHint({
+ input.value = 'o';
+ updatedItem = gl.DropdownUtils.filterHint(input, {
hint: 'label',
}, 'o');
expect(updatedItem.droplab_hidden).toBe(true);
});
it('should return droplab_hidden false when item has no hint', () => {
- const updatedItem = gl.DropdownUtils.filterHint({}, '');
+ const updatedItem = gl.DropdownUtils.filterHint(input, {}, '');
expect(updatedItem.droplab_hidden).toBe(false);
});
});