Commit 317ef7b5 authored by Phil Hughes's avatar Phil Hughes

Fixed failing JS specs

parent 8198d498
...@@ -76,7 +76,6 @@ ...@@ -76,7 +76,6 @@
} }
static getSearchInput(filteredSearchInput) { static getSearchInput(filteredSearchInput) {
const selectionStart = filteredSearchInput.selectionStart;
const inputValue = filteredSearchInput.value; const inputValue = filteredSearchInput.value;
const { right } = gl.DropdownUtils.getInputSelectionPosition(filteredSearchInput); const { right } = gl.DropdownUtils.getInputSelectionPosition(filteredSearchInput);
...@@ -88,7 +87,7 @@ ...@@ -88,7 +87,7 @@
let inputValue = input.value; let inputValue = input.value;
// Replace all spaces inside quote marks with underscores // Replace all spaces inside quote marks with underscores
// This helps with matching the beginning & end of a token:key // This helps with matching the beginning & end of a token:key
inputValue = inputValue.replace(/"(.*?)"/g, str => str.replace(/\s/g, '_') ); inputValue = inputValue.replace(/"(.*?)"/g, str => str.replace(/\s/g, '_'));
// Get the right position for the word selected // Get the right position for the word selected
// Regex matches first space // Regex matches first space
......
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
// Sometimes can end up at end of input // Sometimes can end up at end of input
input.setSelectionRange(selectionStart, selectionStart); input.setSelectionRange(selectionStart, selectionStart);
const inputValue = input.value;
const { right } = gl.DropdownUtils.getInputSelectionPosition(input); const { right } = gl.DropdownUtils.getInputSelectionPosition(input);
input.setSelectionRange(right, right); input.setSelectionRange(right, right);
......
...@@ -67,20 +67,32 @@ ...@@ -67,20 +67,32 @@
}); });
describe('filterHint', () => { describe('filterHint', () => {
let input;
beforeEach(() => {
setFixtures(`
<input type="text" id="test" />
`);
input = document.getElementById('test');
});
it('should filter', () => { it('should filter', () => {
let updatedItem = gl.DropdownUtils.filterHint({ input.value = 'l';
let updatedItem = gl.DropdownUtils.filterHint(input, {
hint: 'label', hint: 'label',
}, 'l'); });
expect(updatedItem.droplab_hidden).toBe(false); expect(updatedItem.droplab_hidden).toBe(false);
updatedItem = gl.DropdownUtils.filterHint({ input.value = 'o';
updatedItem = gl.DropdownUtils.filterHint(input, {
hint: 'label', hint: 'label',
}, 'o'); }, 'o');
expect(updatedItem.droplab_hidden).toBe(true); expect(updatedItem.droplab_hidden).toBe(true);
}); });
it('should return droplab_hidden false when item has no hint', () => { 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); expect(updatedItem.droplab_hidden).toBe(false);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment