/* eslint-env mocha */ /* eslint-disable no-underscore-dangle, no-unused-expressions, class-methods-use-this */ import { expect, fixture, defineCE } from '@open-wc/testing'; import { LitElement, html } from '@lion/core'; import { getDeepActiveElement } from '../../src/utils/get-deep-active-element.js'; describe('getDeepActiveElement()', () => { it('handles document level active elements', async () => { const element = await fixture(`
`); const el1 = element.querySelector('#el-1'); const el2 = element.querySelector('#el-2'); const el3 = element.querySelector('#el-3'); el1.focus(); expect(getDeepActiveElement()).to.eql(el1); el2.focus(); expect(getDeepActiveElement()).to.eql(el2); el3.focus(); expect(getDeepActiveElement()).to.eql(el3); }); it('handles active element inside shadowroots', async () => { const elNestedTag = defineCE( class extends LitElement { render() { return html`