From 13a43fa40214fb2e7c364f1b9c0895b36f625c13 Mon Sep 17 00:00:00 2001 From: Marcos Gil Date: Tue, 4 Feb 2020 08:59:01 +0100 Subject: [PATCH] test(tooltip): dismissable on escape keypress --- packages/tooltip/test/lion-tooltip.test.js | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/tooltip/test/lion-tooltip.test.js b/packages/tooltip/test/lion-tooltip.test.js index 83151b10f..3dabb59b6 100644 --- a/packages/tooltip/test/lion-tooltip.test.js +++ b/packages/tooltip/test/lion-tooltip.test.js @@ -85,6 +85,41 @@ describe('lion-tooltip', () => { expect(el._overlayCtrl.isShown).to.equal(true); }); + it('should show content on focusin and hide on Escape key press', async () => { + const el = await fixture(html` + +
Hey there
+ +
+ `); + const invoker = Array.from(el.children).find(child => child.slot === 'invoker'); + const eventFocusIn = new Event('focusin'); + invoker.dispatchEvent(eventFocusIn); + await el.updateComplete; + expect(el._overlayCtrl.isShown).to.equal(true); + const eventEscapeKeypress = new KeyboardEvent('keyup', { key: 'Escape' }); + invoker.dispatchEvent(eventEscapeKeypress); + await el.updateComplete; + expect(el._overlayCtrl.isShown).to.equal(false); + }); + + it('should show content on mouseenter and hide on Escape key press', async () => { + const el = await fixture(html` + +
Hey there
+ +
+ `); + const eventMouseEnter = new Event('mouseenter'); + el.dispatchEvent(eventMouseEnter); + await el.updateComplete; + expect(el._overlayCtrl.isShown).to.equal(true); + const eventEscapeKeypress = new KeyboardEvent('keyup', { key: 'Escape' }); + document.dispatchEvent(eventEscapeKeypress); + await el.updateComplete; + expect(el._overlayCtrl.isShown).to.equal(false); + }); + it('should tooltip contains html when specified in tooltip content body', async () => { const el = await fixture(html`