From c1bd62152c2fd29e4f15fa8847e7e93d07706475 Mon Sep 17 00:00:00 2001
From: Camille Croci <>
Date: Fri, 9 Dec 2022 16:45:58 +0000
Subject: [PATCH] Add more generic test for button
It should now test that the aria-label of the button contains the visual
label of the button. This will avoir recreating this type of issue in the future
---
.../x-follow-button/__tests__/x-follow-button.test.jsx | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/components/x-follow-button/__tests__/x-follow-button.test.jsx b/components/x-follow-button/__tests__/x-follow-button.test.jsx
index 464b22a37..77ef66f88 100644
--- a/components/x-follow-button/__tests__/x-follow-button.test.jsx
+++ b/components/x-follow-button/__tests__/x-follow-button.test.jsx
@@ -87,6 +87,11 @@ describe('x-follow-button', () => {
'Added ConceptName to myFT: click to remove'
)
})
+
+ it('button aria-label contains the visual label string', () => {
+ const subject = mount()
+ expect(subject.find('button').prop('aria-label')).toContain(subject.find('button').text())
+ })
})
describe('when false', () => {
@@ -109,6 +114,11 @@ describe('x-follow-button', () => {
const subject = mount()
expect(subject.find('button').prop('aria-label')).toEqual('Add to myFT: ConceptName')
})
+
+ it('button aria-label contains the visual label string', () => {
+ const subject = mount()
+ expect(subject.find('button').prop('aria-label')).toContain(subject.find('button').text())
+ })
})
})