diff options
Diffstat (limited to 'spec/javascripts/filtered_search/dropdown_utils_spec.js')
-rw-r--r-- | spec/javascripts/filtered_search/dropdown_utils_spec.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/javascripts/filtered_search/dropdown_utils_spec.js b/spec/javascripts/filtered_search/dropdown_utils_spec.js index 3dc8089cd83..52b54973047 100644 --- a/spec/javascripts/filtered_search/dropdown_utils_spec.js +++ b/spec/javascripts/filtered_search/dropdown_utils_spec.js @@ -10,24 +10,29 @@ describe('Dropdown Utils', () => { describe('getEscapedText', () => { it('should return same word when it has no space', () => { const escaped = DropdownUtils.getEscapedText('textWithoutSpace'); + expect(escaped).toBe('textWithoutSpace'); }); it('should escape with double quotes', () => { let escaped = DropdownUtils.getEscapedText('text with space'); + expect(escaped).toBe('"text with space"'); escaped = DropdownUtils.getEscapedText('won\'t fix'); + expect(escaped).toBe('"won\'t fix"'); }); it('should escape with single quotes', () => { const escaped = DropdownUtils.getEscapedText('won"t fix'); + expect(escaped).toBe('\'won"t fix\''); }); it('should escape with single quotes by default', () => { const escaped = DropdownUtils.getEscapedText('won"t\' fix'); + expect(escaped).toBe('\'won"t\' fix\''); }); }); @@ -50,6 +55,7 @@ describe('Dropdown Utils', () => { input.value = 'roo'; const updatedItem = DropdownUtils.filterWithSymbol('@', input, item); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -57,6 +63,7 @@ describe('Dropdown Utils', () => { input.value = '@roo'; const updatedItem = DropdownUtils.filterWithSymbol('@', input, item); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -69,6 +76,7 @@ describe('Dropdown Utils', () => { input.value = '"'; const updatedItem = DropdownUtils.filterWithSymbol('~', input, multipleWordItem); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -76,6 +84,7 @@ describe('Dropdown Utils', () => { input.value = '~"'; const updatedItem = DropdownUtils.filterWithSymbol('~', input, multipleWordItem); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -83,6 +92,7 @@ describe('Dropdown Utils', () => { input.value = '"community con'; const updatedItem = DropdownUtils.filterWithSymbol('~', input, multipleWordItem); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -90,6 +100,7 @@ describe('Dropdown Utils', () => { input.value = '~"community con'; const updatedItem = DropdownUtils.filterWithSymbol('~', input, multipleWordItem); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -97,6 +108,7 @@ describe('Dropdown Utils', () => { input.value = '\''; const updatedItem = DropdownUtils.filterWithSymbol('~', input, multipleWordItem); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -104,6 +116,7 @@ describe('Dropdown Utils', () => { input.value = '~\''; const updatedItem = DropdownUtils.filterWithSymbol('~', input, multipleWordItem); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -111,6 +124,7 @@ describe('Dropdown Utils', () => { input.value = '\'community con'; const updatedItem = DropdownUtils.filterWithSymbol('~', input, multipleWordItem); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -118,6 +132,7 @@ describe('Dropdown Utils', () => { input.value = '~\'community con'; const updatedItem = DropdownUtils.filterWithSymbol('~', input, multipleWordItem); + expect(updatedItem.droplab_hidden).toBe(false); }); }); @@ -152,17 +167,20 @@ describe('Dropdown Utils', () => { let updatedItem = DropdownUtils.filterHint(config(), { hint: 'label', }); + expect(updatedItem.droplab_hidden).toBe(false); input.value = 'o'; updatedItem = DropdownUtils.filterHint(config(), { hint: 'label', }); + expect(updatedItem.droplab_hidden).toBe(true); }); it('should return droplab_hidden false when item has no hint', () => { const updatedItem = DropdownUtils.filterHint(config(), {}, ''); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -172,6 +190,7 @@ describe('Dropdown Utils', () => { hint: 'label', type: 'array', }); + expect(updatedItem.droplab_hidden).toBe(false); }); @@ -180,12 +199,14 @@ describe('Dropdown Utils', () => { let updatedItem = DropdownUtils.filterHint(config(), { hint: 'milestone', }); + expect(updatedItem.droplab_hidden).toBe(true); updatedItem = DropdownUtils.filterHint(config(), { hint: 'milestone', type: 'string', }); + expect(updatedItem.droplab_hidden).toBe(true); }); }); @@ -205,6 +226,7 @@ describe('Dropdown Utils', () => { }; const updated = DropdownUtils.mergeDuplicateLabels(dataMap, newLabel); + expect(updated[newLabel.title]).toEqual(newLabel); }); @@ -215,6 +237,7 @@ describe('Dropdown Utils', () => { }; const updated = DropdownUtils.mergeDuplicateLabels(dataMap, duplicate); + expect(updated.label.multipleColors).toEqual([dataMap.label.color, duplicate.color]); }); }); @@ -222,21 +245,25 @@ describe('Dropdown Utils', () => { describe('duplicateLabelColor', () => { it('should linear-gradient 2 colors', () => { const gradient = DropdownUtils.duplicateLabelColor(['#FFFFFF', '#000000']); + expect(gradient).toEqual('linear-gradient(#FFFFFF 0%, #FFFFFF 50%, #000000 50%, #000000 100%)'); }); it('should linear-gradient 3 colors', () => { const gradient = DropdownUtils.duplicateLabelColor(['#FFFFFF', '#000000', '#333333']); + expect(gradient).toEqual('linear-gradient(#FFFFFF 0%, #FFFFFF 33%, #000000 33%, #000000 66%, #333333 66%, #333333 100%)'); }); it('should linear-gradient 4 colors', () => { const gradient = DropdownUtils.duplicateLabelColor(['#FFFFFF', '#000000', '#333333', '#DDDDDD']); + expect(gradient).toEqual('linear-gradient(#FFFFFF 0%, #FFFFFF 25%, #000000 25%, #000000 50%, #333333 50%, #333333 75%, #DDDDDD 75%, #DDDDDD 100%)'); }); it('should not linear-gradient more than 4 colors', () => { const gradient = DropdownUtils.duplicateLabelColor(['#FFFFFF', '#000000', '#333333', '#DDDDDD', '#EEEEEE']); + expect(gradient.indexOf('#EEEEEE')).toBe(-1); }); }); @@ -244,6 +271,7 @@ describe('Dropdown Utils', () => { describe('duplicateLabelPreprocessing', () => { it('should set preprocessed to true', () => { const results = DropdownUtils.duplicateLabelPreprocessing([]); + expect(results.preprocessed).toEqual(true); }); @@ -298,6 +326,7 @@ describe('Dropdown Utils', () => { }; DropdownUtils.setDataValueIfSelected(null, selected); + expect(FilteredSearchDropdownManager.addWordToInput.calls.count()).toEqual(1); }); @@ -308,6 +337,7 @@ describe('Dropdown Utils', () => { }; const result = DropdownUtils.setDataValueIfSelected(null, selected); + expect(result).toBe(true); }); @@ -317,6 +347,7 @@ describe('Dropdown Utils', () => { }; const result = DropdownUtils.setDataValueIfSelected(null, selected); + expect(result).toBe(false); }); }); |