Skip to content

Commit

Permalink
Add more generic test for button
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Camille Croci committed Dec 12, 2022
1 parent cb35cc0 commit c1bd621
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/x-follow-button/__tests__/x-follow-button.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<FollowButton isFollowed={true} conceptName={'ConceptName'} />)
expect(subject.find('button').prop('aria-label')).toContain(subject.find('button').text())
})
})

describe('when false', () => {
Expand All @@ -109,6 +114,11 @@ describe('x-follow-button', () => {
const subject = mount(<FollowButton isFollowed={false} conceptName={'ConceptName'} />)
expect(subject.find('button').prop('aria-label')).toEqual('Add to myFT: ConceptName')
})

it('button aria-label contains the visual label string', () => {
const subject = mount(<FollowButton isFollowed={false} conceptName={'ConceptName'} />)
expect(subject.find('button').prop('aria-label')).toContain(subject.find('button').text())
})
})
})

Expand Down

0 comments on commit c1bd621

Please sign in to comment.