|
1 | 1 | import { expect } from '@vaadin/chai-plugins';
|
2 | 2 | import { fixtureSync, keyboardEventFor, nextRender } from '@vaadin/testing-helpers';
|
3 |
| -import { sendKeys } from '@web/test-runner-commands'; |
| 3 | +import { resetMouse, sendKeys, sendMouse } from '@web/test-runner-commands'; |
4 | 4 | import sinon from 'sinon';
|
5 | 5 | import { getAllItems, getDataProvider, getFirstItem } from './helpers.js';
|
6 | 6 |
|
@@ -127,6 +127,36 @@ describe('selecting items', () => {
|
127 | 127 | expect(comboBox.selectedItems).to.deep.equal(['apple']);
|
128 | 128 | });
|
129 | 129 |
|
| 130 | + it('should not unselect previously committed item on outside click', async () => { |
| 131 | + await sendKeys({ down: 'ArrowDown' }); |
| 132 | + await sendKeys({ down: 'ArrowDown' }); |
| 133 | + await sendKeys({ down: 'Enter' }); |
| 134 | + await sendMouse({ type: 'click', position: [200, 200] }); |
| 135 | + await resetMouse(); |
| 136 | + expect(comboBox.selectedItems).to.deep.equal(['apple']); |
| 137 | + }); |
| 138 | + |
| 139 | + it('should not unselect previously committed item on blur after outside click with allow custom value', async () => { |
| 140 | + comboBox.allowCustomValue = true; |
| 141 | + await sendKeys({ down: 'ArrowDown' }); |
| 142 | + await sendKeys({ down: 'ArrowDown' }); |
| 143 | + await sendKeys({ down: 'Enter' }); |
| 144 | + await sendMouse({ type: 'click', position: [200, 200] }); |
| 145 | + await resetMouse(); |
| 146 | + await sendKeys({ down: 'Tab' }); |
| 147 | + expect(comboBox.selectedItems).to.deep.equal(['apple']); |
| 148 | + }); |
| 149 | + |
| 150 | + it('should not set previously committed item to input on blur with allow custom value', async () => { |
| 151 | + comboBox.allowCustomValue = true; |
| 152 | + await sendKeys({ down: 'ArrowDown' }); |
| 153 | + await sendKeys({ down: 'ArrowDown' }); |
| 154 | + await sendKeys({ down: 'Enter' }); |
| 155 | + await sendKeys({ down: 'Tab' }); |
| 156 | + expect(comboBox.filter).to.equal(''); |
| 157 | + expect(inputElement.value).to.equal(''); |
| 158 | + }); |
| 159 | + |
130 | 160 | it('should un-select item when using clear() method', () => {
|
131 | 161 | comboBox.selectedItems = ['orange'];
|
132 | 162 | comboBox.clear();
|
|
0 commit comments