11import { expect } from '@esm-bundle/chai' ;
2- import { aTimeout , fixtureSync , nextFrame , nextRender } from '@vaadin/testing-helpers' ;
2+ import { fixtureSync , nextFrame , nextRender } from '@vaadin/testing-helpers' ;
33import { sendKeys } from '@web/test-runner-commands' ;
44import sinon from 'sinon' ;
55import '../vaadin-radio-group.js' ;
@@ -62,10 +62,6 @@ describe('radio-group', () => {
6262 buttons = [ ...group . querySelectorAll ( 'vaadin-radio-button' ) ] ;
6363 } ) ;
6464
65- it ( 'should set aria-disabled to true when disabled' , ( ) => {
66- expect ( group . getAttribute ( 'aria-disabled' ) ) . to . equal ( 'true' ) ;
67- } ) ;
68-
6965 it ( 'should propagate disabled property to radio buttons' , ( ) => {
7066 buttons . forEach ( ( button ) => {
7167 expect ( button . disabled ) . to . be . true ;
@@ -100,15 +96,6 @@ describe('radio-group', () => {
10096 groupName = group . _fieldName ;
10197 } ) ;
10298
103- it ( 'should generate a group name' , ( ) => {
104- expect ( groupName ) . to . match ( / ^ v a a d i n - r a d i o - g r o u p - \d + $ / ) ;
105- } ) ;
106-
107- it ( 'should set the group name to the radio buttons' , ( ) => {
108- expect ( buttons [ 0 ] . name ) . to . equal ( groupName ) ;
109- expect ( buttons [ 1 ] . name ) . to . equal ( groupName ) ;
110- } ) ;
111-
11299 it ( 'should set the group name to the dynamically added radio buttons' , async ( ) => {
113100 const radio = document . createElement ( 'vaadin-radio-button' ) ;
114101 group . appendChild ( radio ) ;
@@ -182,40 +169,6 @@ describe('radio-group', () => {
182169 } ) ;
183170 } ) ;
184171
185- describe ( 'label property' , ( ) => {
186- beforeEach ( ( ) => {
187- group = fixtureSync ( `<vaadin-radio-group></vaadin-radio-group>` ) ;
188- } ) ;
189-
190- it ( 'should not have has-label attribute by default' , ( ) => {
191- expect ( group . hasAttribute ( 'has-label' ) ) . to . be . false ;
192- } ) ;
193-
194- it ( 'should toggle has-label attribute on label change' , ( ) => {
195- group . label = 'foo' ;
196- expect ( group . hasAttribute ( 'has-label' ) ) . to . be . true ;
197- group . label = null ;
198- expect ( group . hasAttribute ( 'has-label' ) ) . to . be . false ;
199- } ) ;
200- } ) ;
201-
202- describe ( 'aria-required attribute' , ( ) => {
203- beforeEach ( ( ) => {
204- group = fixtureSync ( `<vaadin-radio-group></vaadin-radio-group>` ) ;
205- } ) ;
206-
207- it ( 'should not have aria-required attribute by default' , ( ) => {
208- expect ( group . hasAttribute ( 'aria-required' ) ) . to . be . false ;
209- } ) ;
210-
211- it ( 'should toggle aria-required attribute on required property change' , ( ) => {
212- group . required = true ;
213- expect ( group . getAttribute ( 'aria-required' ) ) . to . equal ( 'true' ) ;
214- group . required = false ;
215- expect ( group . hasAttribute ( 'aria-required' ) ) . to . be . false ;
216- } ) ;
217- } ) ;
218-
219172 describe ( 'focused state' , ( ) => {
220173 beforeEach ( async ( ) => {
221174 group = fixtureSync ( `
@@ -345,18 +298,14 @@ describe('radio-group', () => {
345298 buttons = [ ...group . querySelectorAll ( 'vaadin-radio-button' ) ] ;
346299 } ) ;
347300
348- it ( 'should not have has-value attribute by default' , ( ) => {
349- expect ( group . hasAttribute ( 'has-value' ) ) . to . be . false ;
350- } ) ;
351-
352- it ( 'should set has-value on radio button click' , ( ) => {
301+ it ( 'should add and keep the attribute on radio button click' , ( ) => {
353302 buttons [ 0 ] . click ( ) ;
354303 expect ( group . hasAttribute ( 'has-value' ) ) . to . be . true ;
355304 buttons [ 1 ] . click ( ) ;
356305 expect ( group . hasAttribute ( 'has-value' ) ) . to . be . true ;
357306 } ) ;
358307
359- it ( 'should toggle has-value attribute on value change' , ( ) => {
308+ it ( 'should toggle the attribute on value change' , ( ) => {
360309 group . value = '2' ;
361310 expect ( group . hasAttribute ( 'has-value' ) ) . to . be . true ;
362311 group . value = '' ;
@@ -585,20 +534,6 @@ describe('radio-group', () => {
585534 expect ( spy . calledOnce ) . to . be . true ;
586535 } ) ;
587536
588- it ( 'should reflect required property to attribute' , ( ) => {
589- group . required = true ;
590- expect ( group . hasAttribute ( 'required' ) ) . to . be . true ;
591- group . required = false ;
592- expect ( group . hasAttribute ( 'required' ) ) . to . be . false ;
593- } ) ;
594-
595- it ( 'should reflect invalid property to attribute' , ( ) => {
596- group . invalid = true ;
597- expect ( group . hasAttribute ( 'invalid' ) ) . to . be . true ;
598- group . invalid = false ;
599- expect ( group . hasAttribute ( 'invalid' ) ) . to . be . false ;
600- } ) ;
601-
602537 it ( 'should fire a validated event on validation success' , ( ) => {
603538 const validatedSpy = sinon . spy ( ) ;
604539 group . addEventListener ( 'validated' , validatedSpy ) ;
@@ -621,57 +556,6 @@ describe('radio-group', () => {
621556 } ) ;
622557 } ) ;
623558
624- describe ( 'aria-labelledby' , ( ) => {
625- let error , helper , label ;
626-
627- beforeEach ( ( ) => {
628- group = fixtureSync ( '<vaadin-radio-group helper-text="Choose one" label="Label"></vaadin-radio-group>' ) ;
629- error = group . querySelector ( '[slot=error-message]' ) ;
630- helper = group . querySelector ( '[slot=helper]' ) ;
631- label = group . querySelector ( '[slot=label]' ) ;
632- } ) ;
633-
634- it ( 'should add label and helper text to aria-labelledby when field is valid' , ( ) => {
635- const aria = group . getAttribute ( 'aria-labelledby' ) ;
636- expect ( aria ) . to . include ( helper . id ) ;
637- expect ( aria ) . to . not . include ( error . id ) ;
638- expect ( aria ) . to . include ( label . id ) ;
639- } ) ;
640-
641- it ( 'should add error message to aria-labelledby when field is invalid' , async ( ) => {
642- group . invalid = true ;
643- await aTimeout ( 0 ) ;
644- const aria = group . getAttribute ( 'aria-labelledby' ) ;
645- expect ( aria ) . to . include ( helper . id ) ;
646- expect ( aria ) . to . include ( error . id ) ;
647- expect ( aria ) . to . include ( label . id ) ;
648- } ) ;
649- } ) ;
650-
651- describe ( 'custom helper' , ( ) => {
652- let group , helper ;
653-
654- beforeEach ( async ( ) => {
655- group = fixtureSync ( `
656- <vaadin-radio-group>
657- <div slot="helper">Custom helper</div>
658- </vaadin-radio-group>
659- ` ) ;
660- await nextFrame ( ) ;
661- helper = group . querySelector ( '[slot=helper]' ) ;
662- } ) ;
663-
664- it ( 'should set has-helper attribute' , ( ) => {
665- expect ( group . hasAttribute ( 'has-helper' ) ) . to . be . true ;
666- } ) ;
667-
668- it ( 'should remove has-helper attribute when the custom helper is removed' , async ( ) => {
669- group . removeChild ( helper ) ;
670- await nextFrame ( ) ;
671- expect ( group . hasAttribute ( 'has-helper' ) ) . to . be . false ;
672- } ) ;
673- } ) ;
674-
675559 describe ( 'initial value' , ( ) => {
676560 beforeEach ( async ( ) => {
677561 group = fixtureSync ( `
0 commit comments