From 3f324eed02f24f817e7d75bc7d37c210644a06ee Mon Sep 17 00:00:00 2001 From: Nathan Walters Date: Tue, 5 Jul 2022 22:15:50 -0700 Subject: Handle non-empty whitespace `textContent` in Tooltip trigger (#36588) --- js/tests/unit/tooltip.spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'js/tests') 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 = ' ' + + 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 = '' -- cgit v1.2.3