11import { expect } from '@esm-bundle/chai' ;
2- import { fire , fixtureSync , mousedown , mouseup , nextFrame } from '@vaadin/testing-helpers' ;
2+ import { fire , fixtureSync , mousedown , mouseup , nextFrame , nextRender , nextUpdate } from '@vaadin/testing-helpers' ;
33import { resetMouse , sendKeys , sendMouse } from '@web/test-runner-commands' ;
44import sinon from 'sinon' ;
5- import '../vaadin-radio-button.js' ;
65
76describe ( 'radio-button' , ( ) => {
87 let radio , input , label ;
@@ -25,8 +24,9 @@ describe('radio-button', () => {
2524 } ) ;
2625
2726 describe ( 'default' , ( ) => {
28- beforeEach ( ( ) => {
27+ beforeEach ( async ( ) => {
2928 radio = fixtureSync ( '<vaadin-radio-button label="Label"></vaadin-radio-button>' ) ;
29+ await nextRender ( ) ;
3030 label = radio . querySelector ( '[slot=label]' ) ;
3131 } ) ;
3232
@@ -44,8 +44,9 @@ describe('radio-button', () => {
4444 } ) ;
4545
4646 describe ( 'native input' , ( ) => {
47- beforeEach ( ( ) => {
47+ beforeEach ( async ( ) => {
4848 radio = fixtureSync ( '<vaadin-radio-button></vaadin-radio-button>' ) ;
49+ await nextRender ( ) ;
4950 input = radio . querySelector ( '[slot=input]' ) ;
5051 label = radio . querySelector ( '[slot=label]' ) ;
5152 } ) ;
@@ -110,8 +111,9 @@ describe('radio-button', () => {
110111 } ) ;
111112
112113 describe ( 'disabled attribute' , ( ) => {
113- beforeEach ( ( ) => {
114+ beforeEach ( async ( ) => {
114115 radio = fixtureSync ( '<vaadin-radio-button disabled></vaadin-radio-button>' ) ;
116+ await nextRender ( ) ;
115117 input = radio . querySelector ( '[slot=input]' ) ;
116118 label = radio . querySelector ( '[slot=label]' ) ;
117119 } ) ;
@@ -138,8 +140,9 @@ describe('radio-button', () => {
138140
139141 // TODO: A legacy suit. Replace with snapshot tests when possible.
140142 describe ( 'active attribute' , ( ) => {
141- beforeEach ( ( ) => {
143+ beforeEach ( async ( ) => {
142144 radio = fixtureSync ( '<vaadin-radio-button></vaadin-radio-button>' ) ;
145+ await nextRender ( ) ;
143146 input = radio . querySelector ( '[slot=input]' ) ;
144147 } ) ;
145148
@@ -167,8 +170,9 @@ describe('radio-button', () => {
167170 describe ( 'change event' , ( ) => {
168171 let spy ;
169172
170- beforeEach ( ( ) => {
173+ beforeEach ( async ( ) => {
171174 radio = fixtureSync ( '<vaadin-radio-button></vaadin-radio-button>' ) ;
175+ await nextRender ( ) ;
172176 label = radio . querySelector ( '[slot=label]' ) ;
173177 input = radio . querySelector ( '[slot=input]' ) ;
174178
@@ -195,19 +199,22 @@ describe('radio-button', () => {
195199 expect ( spy . calledOnce ) . to . be . true ;
196200 } ) ;
197201
198- it ( 'should not fire on programmatic toggle' , ( ) => {
202+ it ( 'should not fire on programmatic toggle' , async ( ) => {
199203 radio . checked = true ;
204+ await nextUpdate ( radio ) ;
200205 expect ( spy . called ) . to . be . false ;
201206 } ) ;
202207
203- it ( 'should not fire on input click when checked' , ( ) => {
208+ it ( 'should not fire on input click when checked' , async ( ) => {
204209 radio . checked = true ;
210+ await nextUpdate ( radio ) ;
205211 input . click ( ) ;
206212 expect ( spy . called ) . to . be . false ;
207213 } ) ;
208214
209- it ( 'should not fire on label click when checked' , ( ) => {
215+ it ( 'should not fire on label click when checked' , async ( ) => {
210216 radio . checked = true ;
217+ await nextUpdate ( radio ) ;
211218 label . click ( ) ;
212219 expect ( spy . called ) . to . be . false ;
213220 } ) ;
@@ -227,23 +234,26 @@ describe('radio-button', () => {
227234
228235 describe ( 'delegation' , ( ) => {
229236 describe ( 'name attribute' , ( ) => {
230- beforeEach ( ( ) => {
237+ beforeEach ( async ( ) => {
231238 radio = fixtureSync ( `<vaadin-radio-button name="Name"></vaadin-radio-button>` ) ;
239+ await nextRender ( ) ;
232240 input = radio . querySelector ( '[slot=input]' ) ;
233241 } ) ;
234242
235- it ( 'should delegate name attribute to the input' , ( ) => {
243+ it ( 'should delegate name attribute to the input' , async ( ) => {
236244 expect ( input . getAttribute ( 'name' ) ) . to . equal ( 'Name' ) ;
237245
238246 radio . removeAttribute ( 'name' ) ;
247+ await nextUpdate ( radio ) ;
239248 expect ( input . hasAttribute ( 'name' ) ) . to . be . false ;
240249 } ) ;
241250 } ) ;
242251 } ) ;
243252
244253 describe ( 'has-label attribute' , ( ) => {
245- beforeEach ( ( ) => {
254+ beforeEach ( async ( ) => {
246255 radio = fixtureSync ( '<vaadin-radio-button></vaadin-radio-button>' ) ;
256+ await nextRender ( ) ;
247257 } ) ;
248258
249259 it ( 'should not set has-label attribute when label content is empty' , ( ) => {
0 commit comments