aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorNathan Walters <[email protected]>2022-07-05 22:15:50 -0700
committerGitHub <[email protected]>2022-07-06 07:15:50 +0200
commit3f324eed02f24f817e7d75bc7d37c210644a06ee (patch)
tree838293607d651236c90bbb1a33f2566e01321b23 /js/tests
parent7d0b224df49f75f9860ea1c3a6b54022a359c56f (diff)
downloadbootstrap-3f324eed02f24f817e7d75bc7d37c210644a06ee.tar.xz
bootstrap-3f324eed02f24f817e7d75bc7d37c210644a06ee.zip
Handle non-empty whitespace `textContent` in Tooltip trigger (#36588)
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/tooltip.spec.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.spec.js b/js/tests/unit/tooltip.spec.js
index 1431d837d..c8ab06818 100644
--- a/js/tests/unit/tooltip.spec.js
+++ b/js/tests/unit/tooltip.spec.js
@@ -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>'