diff --git a/src/__tests__/ariaAttributes.js b/src/__tests__/ariaAttributes.js index 1ceb210d..2f19840c 100644 --- a/src/__tests__/ariaAttributes.js +++ b/src/__tests__/ariaAttributes.js @@ -258,3 +258,57 @@ test('`expanded: true|false` matches `expanded` elements with proper role', () = expect(getByRole('button', {expanded: true})).toBeInTheDocument() expect(getByRole('button', {expanded: false})).toBeInTheDocument() }) + +test('`disabled` throws on unsupported roles', () => { + const {getByRole} = render( + `
Hello, Dave!
`, + ) + expect(() => + getByRole('alert', {disabled: true}), + ).toThrowErrorMatchingInlineSnapshot( + `"aria-disabled" is not supported on role "alert".`, + ) +}) + +test('`disabled: true|false` matches `disabled` buttons', () => { + const {getByRole} = renderIntoDocument( + `
+
`, + ) + expect(getByRole('button', {disabled: true})).toBeInTheDocument() + expect(getByRole('button', {disabled: false})).toBeInTheDocument() +}) + +test('`disabled: true|false` matches `aria-disabled` buttons', () => { + const {getByRole} = renderIntoDocument( + `
+
`, + ) + expect(getByRole('button', {disabled: true})).toBeInTheDocument() + expect(getByRole('button', {disabled: false})).toBeInTheDocument() +}) + +test('`disabled` attributes overrides `aria-dsiabled`', () => { + const {getByRole} = renderIntoDocument( + `
+
`, + ) + expect(getByRole('button', {disabled: true})).toBeInTheDocument() +}) + +test('consider `disabled` attribute only if supported', () => { + const {getByRole, queryByRole} = renderIntoDocument( + `
+