@@ -180,17 +180,6 @@ describe('radio-group', () => {
180
180
expect ( buttons [ 1 ] . checked ) . to . be . false ;
181
181
} ) ;
182
182
183
- it ( 'should not have has-value attribute by default' , ( ) => {
184
- expect ( group . hasAttribute ( 'has-value' ) ) . to . be . false ;
185
- } ) ;
186
-
187
- it ( 'should toggle has-value attribute on value change' , ( ) => {
188
- group . value = '2' ;
189
- expect ( group . hasAttribute ( 'has-value' ) ) . to . be . true ;
190
- group . value = '' ;
191
- expect ( group . hasAttribute ( 'has-value' ) ) . to . be . false ;
192
- } ) ;
193
-
194
183
it ( 'should dispatch value-changed event when value changes' , ( ) => {
195
184
const spy = sinon . spy ( ) ;
196
185
group . addEventListener ( 'value-changed' , spy ) ;
@@ -215,6 +204,26 @@ describe('radio-group', () => {
215
204
} ) ;
216
205
} ) ;
217
206
207
+ describe ( 'has-value attribute' , ( ) => {
208
+ it ( 'should not have has-value attribute by default' , ( ) => {
209
+ expect ( group . hasAttribute ( 'has-value' ) ) . to . be . false ;
210
+ } ) ;
211
+
212
+ it ( 'should set has-value on radio button click' , ( ) => {
213
+ buttons [ 0 ] . click ( ) ;
214
+ expect ( group . hasAttribute ( 'has-value' ) ) . to . be . true ;
215
+ buttons [ 1 ] . click ( ) ;
216
+ expect ( group . hasAttribute ( 'has-value' ) ) . to . be . true ;
217
+ } ) ;
218
+
219
+ it ( 'should toggle has-value attribute on value change' , ( ) => {
220
+ group . value = '2' ;
221
+ expect ( group . hasAttribute ( 'has-value' ) ) . to . be . true ;
222
+ group . value = '' ;
223
+ expect ( group . hasAttribute ( 'has-value' ) ) . to . be . false ;
224
+ } ) ;
225
+ } ) ;
226
+
218
227
describe ( 'roving tabindex' , ( ) => {
219
228
it ( 'sets focus to the first element by default' , ( ) => {
220
229
expect ( buttons [ 0 ] . tabIndex ) . to . eq ( 0 ) ;
@@ -526,6 +535,12 @@ describe('radio-group', () => {
526
535
group . invalid = false ;
527
536
expect ( group . hasAttribute ( 'invalid' ) ) . to . be . false ;
528
537
} ) ;
538
+
539
+ it ( 'should run validation only once on radio button click' , ( ) => {
540
+ const spy = sinon . spy ( group , 'validate' ) ;
541
+ buttons [ 1 ] . click ( ) ;
542
+ expect ( spy . calledOnce ) . to . be . true ;
543
+ } ) ;
529
544
} ) ;
530
545
531
546
describe ( 'errorMessage property' , ( ) => {
0 commit comments