Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit fd88d40

Browse files
Shi Shucopybara-github
authored andcommitted
test(tooltip): Add mouseleave event test checks for persistent rich tooltips.
PiperOrigin-RevId: 346333131
1 parent afb6889 commit fd88d40

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

packages/mdc-tooltip/test/component.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,36 @@ describe('MDCTooltip', () => {
453453
expect(anchorElem.getAttribute('aria-expanded')).toEqual('false');
454454
});
455455

456+
it('aria-expanded remains true on anchor when mouseleave anchor while tooltip is shown',
457+
() => {
458+
const tooltipElem = fixture.querySelector<HTMLElement>('#tt0')!;
459+
const anchorElem =
460+
fixture.querySelector<HTMLElement>('[aria-describedby]')!;
461+
MDCTooltip.attachTo(tooltipElem);
462+
463+
emitEvent(anchorElem, 'click');
464+
expect(tooltipElem.getAttribute('aria-hidden')).toEqual('false');
465+
expect(anchorElem.getAttribute('aria-expanded')).toEqual('true');
466+
emitEvent(anchorElem, 'mouseleave');
467+
468+
expect(anchorElem.getAttribute('aria-expanded')).toEqual('true');
469+
});
470+
471+
it('aria-expanded remains true on anchor when mouseleave tooltip while tooltip is shown',
472+
() => {
473+
const tooltipElem = fixture.querySelector<HTMLElement>('#tt0')!;
474+
const anchorElem =
475+
fixture.querySelector<HTMLElement>('[aria-describedby]')!;
476+
MDCTooltip.attachTo(tooltipElem);
477+
478+
emitEvent(anchorElem, 'click');
479+
expect(tooltipElem.getAttribute('aria-hidden')).toEqual('false');
480+
expect(anchorElem.getAttribute('aria-expanded')).toEqual('true');
481+
emitEvent(tooltipElem, 'mouseleave');
482+
483+
expect(anchorElem.getAttribute('aria-expanded')).toEqual('true');
484+
});
485+
456486
it('aria-expanded becomes false on anchor when anchor blurs and non-tooltip element is focused',
457487
() => {
458488
// FocusEvent is not supported on IE11 so this test will not be run on

0 commit comments

Comments
 (0)