diff --git a/src/__tests__/ariaAttributes.js b/src/__tests__/ariaAttributes.js
index 56590aac..3f504c87 100644
--- a/src/__tests__/ariaAttributes.js
+++ b/src/__tests__/ariaAttributes.js
@@ -1,4 +1,4 @@
-import {render} from './helpers/test-utils'
+import {render, renderIntoDocument} from './helpers/test-utils'
test('`selected` throws on unsupported roles', () => {
const {getByRole} = render(``)
@@ -9,6 +9,59 @@ test('`selected` throws on unsupported roles', () => {
)
})
+test('`checked` throws on unsupported roles', () => {
+ const {getByRole} = render(``)
+ expect(() =>
+ getByRole('textbox', {checked: true}),
+ ).toThrowErrorMatchingInlineSnapshot(
+ `"\\"aria-checked\\" is not supported on role \\"textbox\\"."`,
+ )
+})
+
+test('`checked: true|false` matches `checked` checkboxes', () => {
+ const {getByRole} = renderIntoDocument(
+ `
+
+
+
`,
+ )
+ expect(getByRole('checkbox', {checked: true})).toBeInTheDocument()
+ expect(getByRole('checkbox', {checked: false})).toBeInTheDocument()
+})
+
+test('`checked: true|false` matches `checked` elements with proper role', () => {
+ const {getByRole} = renderIntoDocument(
+ `
+ ✔
+ 𝒙
+
`,
+ )
+ expect(getByRole('checkbox', {checked: true})).toBeInTheDocument()
+ expect(getByRole('checkbox', {checked: false})).toBeInTheDocument()
+})
+
+test('`checked: true|false` does not match element in `indeterminate` state', () => {
+ const {queryByRole, getByLabelText} = renderIntoDocument(
+ `
+ not so much
+
+
+
`,
+ )
+ getByLabelText(/indeteminate yes/i).indeterminate = true
+ getByLabelText(/indeteminate no/i).indeterminate = true
+
+ expect(
+ queryByRole('checkbox', {checked: true, name: /indeteminate yes/i}),
+ ).toBeNull()
+ expect(
+ queryByRole('checkbox', {checked: false, name: /indeteminate no/i}),
+ ).toBeNull()
+ expect(
+ queryByRole('checkbox', {checked: true, name: /not so much/i}),
+ ).toBeNull()
+})
+
test('`selected: true` matches `aria-selected="true"` on supported roles', () => {
const {getAllByRole} = render(`