Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
nwalters512 authored and GeoSot committed Jul 4, 2022
1 parent 38bb726 commit 2c072a2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions js/tests/unit/tooltip.spec.js
Expand Up @@ -1358,6 +1358,25 @@ describe('Tooltip', () => {
})
})

it('should add the aria-label attribute when element text content is a whitespace string', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="A tooltip"><span> </span></a>'

const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)

tooltipEl.addEventListener('shown.bs.tooltip', () => {
const tooltipShown = document.querySelector('.tooltip')

expect(tooltipShown).not.toBeNull()
expect(tooltipEl.getAttribute('aria-label')).toEqual('A tooltip')
resolve()
})

tooltip.show()
})
})

it('should not add the aria-label attribute if the attribute already exists', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" aria-label="Different label" title="Another tooltip"></a>'
Expand Down

0 comments on commit 2c072a2

Please sign in to comment.