From 0427531fbc3baa15e32db81e795f5e1fc387548a Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 3 May 2020 17:35:29 +0200 Subject: [PATCH 1/2] feat(ByRole): Allow filter by selected state --- src/__tests__/ariaAttributes.js | 94 +++++++++++++++++++++++++++++++++ src/queries/role.js | 17 ++++++ src/role-helpers.js | 22 ++++++++ 3 files changed, 133 insertions(+) create mode 100644 src/__tests__/ariaAttributes.js diff --git a/src/__tests__/ariaAttributes.js b/src/__tests__/ariaAttributes.js new file mode 100644 index 00000000..0d4bb538 --- /dev/null +++ b/src/__tests__/ariaAttributes.js @@ -0,0 +1,94 @@ +import {render} from './helpers/test-utils' + +test('`selected` throws on unsupported roles', () => { + const {getByRole} = render(``) + expect(() => + getByRole('textbox', {selected: true}), + ).toThrowErrorMatchingInlineSnapshot( + `"\\"aria-selected\\" is not supported on role \\"textbox\\"."`, + ) +}) + +test('`selected: true` matches `aria-selected="true"` on supported roles', () => { + const {getAllByRole} = render(` + +
+
+
+
+
+
+
+
+
+
+ + +