From 369a2af633616ad8630730a99904918aee546ca7 Mon Sep 17 00:00:00 2001 From: Aman Mahajan Date: Wed, 3 Jan 2024 11:41:31 -0600 Subject: [PATCH 1/2] dom-accessibility-api@0.6.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5ab9a2..1f6df71 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "aria-query": "^5.0.0", "chalk": "^3.0.0", "css.escape": "^1.5.1", - "dom-accessibility-api": "^0.5.6", + "dom-accessibility-api": "^0.6.3", "lodash": "^4.17.15", "redent": "^3.0.0" }, From 8f68a89493fb5784abd4386b9ffa5163fb7b28ee Mon Sep 17 00:00:00 2001 From: Aman Mahajan Date: Wed, 3 Jan 2024 12:01:36 -0600 Subject: [PATCH 2/2] Update Readme and add tests --- README.md | 9 +++++++++ .../to-have-accessible-description.js | 20 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/README.md b/README.md index fa0fced..33961ef 100644 --- a/README.md +++ b/README.md @@ -594,6 +594,12 @@ make a partial match passing a regular expression, or by using aria-describedby="t1" /> The logo of Our Company +Company logo ``` ```js @@ -606,6 +612,9 @@ expect(getByTestId('logo')).not.toHaveAccessibleDescription('Company logo') expect(getByTestId('logo')).toHaveAccessibleDescription( 'The logo of Our Company', ) +expect(getByTestId('logo2')).toHaveAccessibleDescription( + 'The logo of Our Company', +) ```
diff --git a/src/__tests__/to-have-accessible-description.js b/src/__tests__/to-have-accessible-description.js index 49c7f20..794d564 100644 --- a/src/__tests__/to-have-accessible-description.js +++ b/src/__tests__/to-have-accessible-description.js @@ -57,6 +57,26 @@ describe('.toHaveAccessibleDescription', () => { }).toThrow(/expected element not to have accessible description/i) }) + it('works with aria-description attribute', () => { + const {queryByTestId} = render(` + Company logo + `) + + const logo = queryByTestId('logo') + expect(logo).not.toHaveAccessibleDescription('Company logo') + expect(logo).toHaveAccessibleDescription('The logo of Our Company') + expect(logo).toHaveAccessibleDescription(/logo of our company/i) + expect(logo).toHaveAccessibleDescription( + expect.stringContaining('logo of Our Company'), + ) + expect(() => { + expect(logo).toHaveAccessibleDescription("Our company's logo") + }).toThrow(/expected element to have accessible description/i) + expect(() => { + expect(logo).not.toHaveAccessibleDescription('The logo of Our Company') + }).toThrow(/expected element not to have accessible description/i) + }) + it('handles multiple ids', () => { const {queryByTestId} = render(`