diff options
Diffstat (limited to 'polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_test.html')
-rw-r--r-- | polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_test.html | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_test.html b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_test.html index 1995688433..d4d54ffcf6 100644 --- a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_test.html +++ b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_test.html @@ -1,5 +1,6 @@ <!DOCTYPE html> <!-- +@license Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,7 +42,7 @@ limitations under the License. element = fixture('basic'); element.open(); element.suggestions = [ - {dataValue: 'test value 1', name: 'test name 1', text: 1}, + {dataValue: 'test value 1', name: 'test name 1', text: 1, label: 'hi'}, {dataValue: 'test value 2', name: 'test name 2', text: 2}]; flushAsynchronousOperations(); }); @@ -51,6 +52,12 @@ limitations under the License. if (element.isOpen) element.close(); }); + test('shows labels', () => { + const els = element.$.suggestions.querySelectorAll('li'); + assert.equal(els[0].innerText.trim(), '1\nhi'); + assert.equal(els[1].innerText.trim(), '2'); + }); + test('escape key', done => { const closeSpy = sandbox.spy(element, 'close'); MockInteractions.pressAndReleaseKeyOn(element, 27); @@ -124,6 +131,19 @@ limitations under the License. }); }); + test('tapping child still selects item', () => { + const itemSelectedStub = sandbox.stub(); + element.addEventListener('item-selected', itemSelectedStub); + + MockInteractions.tap(element.$.suggestions.querySelectorAll('li')[0] + .lastElementChild); + flushAsynchronousOperations(); + assert.deepEqual(itemSelectedStub.lastCall.args[0].detail, { + trigger: 'tap', + selected: element.$.suggestions.querySelectorAll('li')[0], + }); + }); + test('updated suggestions resets cursor stops', () => { resetStopsSpy = sandbox.spy(element, '_resetCursorStops'); element.suggestions = []; |