@@ -36,6 +36,28 @@ test('`expanded` throws on unsupported roles', () => {
36
36
)
37
37
} )
38
38
39
+ test ( '`busy` throws on unsupported roles' , ( ) => {
40
+ const { getByRole} = render (
41
+ `<div aria-busy="true" role="none">Hello, Dave!</div>` ,
42
+ )
43
+ expect ( ( ) =>
44
+ getByRole ( 'none' , { busy : true } ) ,
45
+ ) . toThrowErrorMatchingInlineSnapshot (
46
+ `"aria-busy" is not supported on role "none".` ,
47
+ )
48
+ } )
49
+
50
+ test ( '`busy: true|false` matches `busy` regions' , ( ) => {
51
+ const { getByRole} = renderIntoDocument (
52
+ `<div>
53
+ <div role="log" aria-busy="true" />
54
+ <div role="log" aria-busy="false" />
55
+ </div>` ,
56
+ )
57
+ expect ( getByRole ( 'log' , { busy : true } ) ) . toBeInTheDocument ( )
58
+ expect ( getByRole ( 'log' , { busy : false } ) ) . toBeInTheDocument ( )
59
+ } )
60
+
39
61
test ( '`checked: true|false` matches `checked` checkboxes' , ( ) => {
40
62
const { getByRole} = renderIntoDocument (
41
63
`<div>
@@ -237,6 +259,105 @@ test('`level` throws on unsupported roles', () => {
237
259
)
238
260
} )
239
261
262
+ test ( '`value.now` throws on unsupported roles' , ( ) => {
263
+ const { getByRole} = render ( `<button aria-valuenow="1">Button</button>` )
264
+ expect ( ( ) =>
265
+ getByRole ( 'button' , { value : { now : 1 } } ) ,
266
+ ) . toThrowErrorMatchingInlineSnapshot (
267
+ `"aria-valuenow" is not supported on role "button".` ,
268
+ )
269
+ } )
270
+
271
+ test ( '`value.now: number` matches `aria-valuenow` on widgets' , ( ) => {
272
+ const { getByRole} = renderIntoDocument (
273
+ `<div>
274
+ <button role="spinbutton" />
275
+ <button role="spinbutton" aria-valuenow="5" />
276
+ <button role="spinbutton" aria-valuenow="10" />
277
+ </div>` ,
278
+ )
279
+ expect ( getByRole ( 'spinbutton' , { value : { now : 5 } } ) ) . toBeInTheDocument ( )
280
+ expect ( getByRole ( 'spinbutton' , { value : { now : 10 } } ) ) . toBeInTheDocument ( )
281
+ } )
282
+
283
+ test ( '`value.max` throws on unsupported roles' , ( ) => {
284
+ const { getByRole} = render ( `<button aria-valuemax="1">Button</button>` )
285
+ expect ( ( ) =>
286
+ getByRole ( 'button' , { value : { max : 1 } } ) ,
287
+ ) . toThrowErrorMatchingInlineSnapshot (
288
+ `"aria-valuemax" is not supported on role "button".` ,
289
+ )
290
+ } )
291
+
292
+ test ( '`value.max: number` matches `aria-valuemax` on widgets' , ( ) => {
293
+ const { getByRole} = renderIntoDocument (
294
+ `<div>
295
+ <button role="spinbutton" />
296
+ <button role="spinbutton" aria-valuemax="5" />
297
+ <button role="spinbutton" aria-valuemax="10" />
298
+ </div>` ,
299
+ )
300
+ expect ( getByRole ( 'spinbutton' , { value : { max : 5 } } ) ) . toBeInTheDocument ( )
301
+ expect ( getByRole ( 'spinbutton' , { value : { max : 10 } } ) ) . toBeInTheDocument ( )
302
+ } )
303
+
304
+ test ( '`value.min` throws on unsupported roles' , ( ) => {
305
+ const { getByRole} = render ( `<button aria-valuemin="1">Button</button>` )
306
+ expect ( ( ) =>
307
+ getByRole ( 'button' , { value : { min : 1 } } ) ,
308
+ ) . toThrowErrorMatchingInlineSnapshot (
309
+ `"aria-valuemin" is not supported on role "button".` ,
310
+ )
311
+ } )
312
+
313
+ test ( '`value.min: number` matches `aria-valuemin` on widgets' , ( ) => {
314
+ const { getByRole} = renderIntoDocument (
315
+ `<div>
316
+ <button role="spinbutton" />
317
+ <button role="spinbutton" aria-valuemin="5" />
318
+ <button role="spinbutton" aria-valuemin="10" />
319
+ </div>` ,
320
+ )
321
+ expect ( getByRole ( 'spinbutton' , { value : { min : 5 } } ) ) . toBeInTheDocument ( )
322
+ expect ( getByRole ( 'spinbutton' , { value : { min : 10 } } ) ) . toBeInTheDocument ( )
323
+ } )
324
+
325
+ test ( '`value.text` throws on unsupported roles' , ( ) => {
326
+ const { getByRole} = render ( `<button aria-valuetext="one">Button</button>` )
327
+ expect ( ( ) =>
328
+ getByRole ( 'button' , { value : { text : 'one' } } ) ,
329
+ ) . toThrowErrorMatchingInlineSnapshot (
330
+ `"aria-valuetext" is not supported on role "button".` ,
331
+ )
332
+ } )
333
+
334
+ test ( '`value.text: Matcher` matches `aria-valuetext` on widgets' , ( ) => {
335
+ const { getAllByRole, getByRole} = renderIntoDocument (
336
+ `<div>
337
+ <button role="spinbutton" />
338
+ <button role="spinbutton" aria-valuetext="zero" />
339
+ <button role="spinbutton" aria-valuetext="few" />
340
+ <button role="spinbutton" aria-valuetext="many" />
341
+ </div>` ,
342
+ )
343
+ expect ( getByRole ( 'spinbutton' , { value : { text : 'zero' } } ) ) . toBeInTheDocument ( )
344
+ expect ( getAllByRole ( 'spinbutton' , { value : { text : / f e w | m a n y / } } ) ) . toHaveLength (
345
+ 2 ,
346
+ )
347
+ } )
348
+
349
+ test ( '`value.*` must all match if specified' , ( ) => {
350
+ const { getByRole} = renderIntoDocument (
351
+ `<div>
352
+ <button role="spinbutton" aria-valuemin="0" aria-valuenow="1" aria-valuemax="10" aria-valuetext="eins" />
353
+ <button role="spinbutton" aria-valuemin="0" aria-valuenow="1" aria-valuemax="10" aria-valuetext="one" />
354
+ </div>` ,
355
+ )
356
+ expect (
357
+ getByRole ( 'spinbutton' , { value : { now : 1 , text : 'one' } } ) ,
358
+ ) . toBeInTheDocument ( )
359
+ } )
360
+
240
361
test ( '`expanded: true|false` matches `expanded` buttons' , ( ) => {
241
362
const { getByRole} = renderIntoDocument (
242
363
`<div>
0 commit comments