From 328f723008cc39292a9f355e2eafb0fd04740656 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Tue, 7 Dec 2021 15:51:56 +0200 Subject: Tooltip: remove title attribute before show & add tests (#35456) --- js/tests/unit/tooltip.spec.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'js/tests') diff --git a/js/tests/unit/tooltip.spec.js b/js/tests/unit/tooltip.spec.js index f92b74d96..9054c0f64 100644 --- a/js/tests/unit/tooltip.spec.js +++ b/js/tests/unit/tooltip.spec.js @@ -180,6 +180,15 @@ describe('Tooltip', () => { expect(getPopperConfig).toHaveBeenCalled() expect(popperConfig.placement).toEqual('left') }) + + it('should use original title, if not "data-bs-title" is given', () => { + fixtureEl.innerHTML = '' + + const tooltipEl = fixtureEl.querySelector('a') + const tooltip = new Tooltip(tooltipEl) + + expect(tooltip._config.title).toEqual('Another tooltip') + }) }) describe('enable', () => { @@ -855,6 +864,19 @@ describe('Tooltip', () => { tooltip.show() }) + + it('should remove `title` attribute if exists', done => { + fixtureEl.innerHTML = '' + + const tooltipEl = fixtureEl.querySelector('a') + const tooltip = new Tooltip(tooltipEl) + + tooltipEl.addEventListener('shown.bs.tooltip', () => { + expect(tooltipEl.getAttribute('title')).toBeNull() + done() + }) + tooltip.show() + }) }) describe('hide', () => { -- cgit v1.2.3