From c9b362c4b7ca45e001a01b2a02eb2742baf8ce55 Mon Sep 17 00:00:00 2001 From: "nik.savchenko@nielsen.com" Date: Wed, 5 May 2021 12:11:09 +0300 Subject: [PATCH 1/3] feat(byRole): add documentation for new option of ByRole queries - docs for PR: https://github.com/testing-library/dom-testing-library/pull/943 - according to issue: https://github.com/testing-library/dom-testing-library/issues/864 --- docs/queries/byrole.mdx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/queries/byrole.mdx b/docs/queries/byrole.mdx index f8ac64987..b55b8e5d3 100644 --- a/docs/queries/byrole.mdx +++ b/docs/queries/byrole.mdx @@ -24,6 +24,7 @@ getByRole( selected?: boolean, checked?: boolean, pressed?: boolean, + current?: boolean, expanded?: boolean, queryFallbacks?: boolean, level?: number, @@ -162,6 +163,32 @@ you can get the "👍" button by calling `getByRole('button', { pressed: true }) To learn more about the pressed state see [ARIA `aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed). +### `current` + +Elements can represent the current item within a container or set of related +elements. + +Despite current have list of values: `date`, `location`, `page`, `step`, `time`, +`true`, `false` + +You can filter the returned elements by their current status by setting +`current: true` (for any valid value) or `current: false` (for false). + +For example in + +```html + +
+ 👍 + 👎 +
+ +``` + +you can get the "👍" link by calling `getByRole('button', { current: true })`. +To learn more about the current status see +[ARIA `aria-current`](https://www.w3.org/TR/wai-aria-1.2/#aria-current). + ### `expanded` You can filter the returned elements by their expanded state by setting From cab4244ae79bd67dfa42ff3f94258367b21cd014 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 25 Aug 2021 14:28:43 +0200 Subject: [PATCH 2/3] re-order --- docs/queries/byrole.mdx | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/queries/byrole.mdx b/docs/queries/byrole.mdx index b55b8e5d3..cef5248dc 100644 --- a/docs/queries/byrole.mdx +++ b/docs/queries/byrole.mdx @@ -24,7 +24,7 @@ getByRole( selected?: boolean, checked?: boolean, pressed?: boolean, - current?: boolean, + current?: boolean | string, expanded?: boolean, queryFallbacks?: boolean, level?: number, @@ -143,26 +143,6 @@ state and which elements can have this state see > Checkboxes have a "mixed" state, which is considered neither checked nor > unchecked (details [here](https://www.w3.org/TR/html-aam-1.0/#details-id-56)). -### `pressed` - -Buttons can have a pressed state. You can filter the returned elements by their -pressed state by setting `pressed: true` or `pressed: false`. - -For example in - -```html - -
- - -
- -``` - -you can get the "👍" button by calling `getByRole('button', { pressed: true })`. -To learn more about the pressed state see -[ARIA `aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed). - ### `current` Elements can represent the current item within a container or set of related @@ -189,6 +169,26 @@ you can get the "👍" link by calling `getByRole('button', { current: true })`. To learn more about the current status see [ARIA `aria-current`](https://www.w3.org/TR/wai-aria-1.2/#aria-current). +### `pressed` + +Buttons can have a pressed state. You can filter the returned elements by their +pressed state by setting `pressed: true` or `pressed: false`. + +For example in + +```html + +
+ + +
+ +``` + +you can get the "👍" button by calling `getByRole('button', { pressed: true })`. +To learn more about the pressed state see +[ARIA `aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed). + ### `expanded` You can filter the returned elements by their expanded state by setting From 482ff45816d98b45a6da77efa767ca1498f45aab Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 25 Aug 2021 14:31:44 +0200 Subject: [PATCH 3/3] Update possible `current` values --- docs/queries/byrole.mdx | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/docs/queries/byrole.mdx b/docs/queries/byrole.mdx index cef5248dc..c1c3e2270 100644 --- a/docs/queries/byrole.mdx +++ b/docs/queries/byrole.mdx @@ -145,28 +145,23 @@ state and which elements can have this state see ### `current` -Elements can represent the current item within a container or set of related -elements. - -Despite current have list of values: `date`, `location`, `page`, `step`, `time`, -`true`, `false` - -You can filter the returned elements by their current status by setting -`current: true` (for any valid value) or `current: false` (for false). +You can filter the returned elements by their current state by setting +`current: boolean | string`. +Note that no `aria-current` attribute will match `current: false` since `false` is the default value for `aria-current`. For example in ```html -
- 👍 - 👎 -
+ ``` -you can get the "👍" link by calling `getByRole('button', { current: true })`. -To learn more about the current status see +you can get the "👍" link by calling `getByRole('link', { current: true })` and the "👎" by calling `getByRole('link', { current: false })`. +To learn more about the current state see [ARIA `aria-current`](https://www.w3.org/TR/wai-aria-1.2/#aria-current). ### `pressed`