11import { expect } from '@esm-bundle/chai' ;
2- import { aTimeout , enter , fixtureSync } from '@vaadin/testing-helpers' ;
3- import sinon from 'sinon' ;
2+ import { aTimeout , enter , fixtureSync , nextRender } from '@vaadin/testing-helpers' ;
43import './not-animated-styles.js' ;
54import '../vaadin-combo-box.js' ;
65import { getFocusedItemIndex , setInputValue } from './helpers.js' ;
@@ -9,9 +8,10 @@ describe('external filtering', () => {
98 let comboBox , overlay ;
109
1110 describe ( 'basic' , ( ) => {
12- beforeEach ( ( ) => {
11+ beforeEach ( async ( ) => {
1312 comboBox = fixtureSync ( '<vaadin-combo-box></vaadin-combo-box>' ) ;
1413 comboBox . filteredItems = [ 'foo' , 'bar' , 'baz' ] ;
14+ await nextRender ( ) ;
1515 overlay = comboBox . $ . overlay ;
1616 } ) ;
1717
@@ -50,7 +50,7 @@ describe('external filtering', () => {
5050
5151 it ( 'should update focus when opening with filling filter' , ( ) => {
5252 comboBox . filteredItems = [ 'foo' , 'bar' , 'baz' ] ;
53- comboBox . close ( ) ;
53+ expect ( comboBox . opened ) . to . be . false ;
5454
5555 setInputValue ( comboBox , 'bar' ) ;
5656
@@ -65,17 +65,7 @@ describe('external filtering', () => {
6565
6666 expect ( comboBox . opened ) . to . be . true ;
6767 expect ( comboBox . $ . overlay . hasAttribute ( 'hidden' ) ) . to . be . false ;
68- } ) ;
69-
70- // FIXME(@platosha): Hiding does not play nice with lazy loading.
71- // Should display a loading indicator instead.
72- it . skip ( 'should hide the scroller while loading' , ( ) => {
73- setInputValue ( comboBox , 'foo' ) ;
74-
75- comboBox . loading = true ;
76-
77- expect ( comboBox . opened ) . to . be . true ;
78- expect ( comboBox . _scroller . hidden ) . to . be . true ;
68+ expect ( comboBox . _scroller . hidden ) . to . be . false ;
7969 } ) ;
8070
8171 it ( 'should refresh items after reassignment' , ( ) => {
@@ -94,18 +84,12 @@ describe('external filtering', () => {
9484 expect ( comboBox . hasAttribute ( 'loading' ) ) . to . be . false ;
9585 expect ( overlay . hasAttribute ( 'loading' ) ) . to . be . false ;
9686 } ) ;
97-
98- it ( 'should not perform measurements when loading changes if not opened' , ( ) => {
99- const measureSpy = sinon . spy ( comboBox . inputElement , 'getBoundingClientRect' ) ;
100- comboBox . loading = true ;
101-
102- expect ( measureSpy . called ) . to . be . false ;
103- } ) ;
10487 } ) ;
10588
10689 describe ( 'filtered items attribute' , ( ) => {
107- beforeEach ( ( ) => {
90+ beforeEach ( async ( ) => {
10891 comboBox = fixtureSync ( `<vaadin-combo-box filtered-items='["a", "b", "c"]' value='b'></vaadin-combo-box>` ) ;
92+ await nextRender ( ) ;
10993 } ) ;
11094
11195 it ( 'should not throw when passing filteredItems and value as attributes' , ( ) => {
@@ -115,8 +99,9 @@ describe('external filtering', () => {
11599 } ) ;
116100
117101 describe ( 'value is set after' , ( ) => {
118- beforeEach ( ( ) => {
102+ beforeEach ( async ( ) => {
119103 comboBox = fixtureSync ( `<vaadin-combo-box></vaadin-combo-box>` ) ;
104+ await nextRender ( ) ;
120105 comboBox . filteredItems = [ 'foo' , 'bar' ] ;
121106 comboBox . value = 'foo' ;
122107 } ) ;
@@ -152,8 +137,9 @@ describe('external filtering', () => {
152137 } ) ;
153138
154139 describe ( 'value is set before' , ( ) => {
155- beforeEach ( ( ) => {
140+ beforeEach ( async ( ) => {
156141 comboBox = fixtureSync ( `<vaadin-combo-box value="foo"></vaadin-combo-box>` ) ;
142+ await nextRender ( ) ;
157143 comboBox . filteredItems = [ 'foo' , 'bar' ] ;
158144 } ) ;
159145
@@ -180,8 +166,9 @@ describe('external filtering', () => {
180166 } ) ;
181167
182168 describe ( 'value is set before + autoOpenDisabled' , ( ) => {
183- beforeEach ( ( ) => {
169+ beforeEach ( async ( ) => {
184170 comboBox = fixtureSync ( `<vaadin-combo-box auto-open-disabled value="bar"></vaadin-combo-box>` ) ;
171+ await nextRender ( ) ;
185172 comboBox . filteredItems = [ 'foo' , 'bar' ] ;
186173 } ) ;
187174
@@ -237,8 +224,9 @@ describe('external filtering', () => {
237224 { label : 'Item 2' , value : '2' } ,
238225 ] ;
239226
240- beforeEach ( ( ) => {
227+ beforeEach ( async ( ) => {
241228 comboBox = fixtureSync ( `<vaadin-combo-box></vaadin-combo-box>` ) ;
229+ await nextRender ( ) ;
242230 comboBox . selectedItem = items [ 0 ] ;
243231 comboBox . filteredItems = items ;
244232 } ) ;
0 commit comments