import '../../../dist/zn.min.js'; import { expect, fixture, html, waitUntil } from '@open-wc/testing'; describe('', () => { it('should render a component', async () => { const el = await fixture(html` `); expect(el).to.exist; }); describe('drop panel overflow', () => { const openPanel = async (el: HTMLElement) => { const dropdown = el.shadowRoot!.querySelector('zn-dropdown') as HTMLElement & { show: () => Promise }; await dropdown.show(); await waitUntil(() => el.hasAttribute('open')); await new Promise(resolve => requestAnimationFrame(resolve)); }; const tallContent = html`
tall
`; it('should bound the panel height so it cannot run off the screen', async () => { const el = await fixture(tallContent); await openPanel(el); const frame = el.shadowRoot!.querySelector('.expanding-action__frame')!; expect(frame).to.exist; expect(frame.getBoundingClientRect().height).to.be.at.most(window.innerHeight); }); it('should scroll overflowing content rather than clipping it', async () => { const el = await fixture(tallContent); await openPanel(el); const content = el.shadowRoot!.querySelector('#content')!; expect(getComputedStyle(content).overflowY).to.equal('auto'); expect(content.scrollHeight).to.be.greaterThan(content.clientHeight); }); it('should honour an explicit max-height', async () => { const el = await fixture(html`
tall
`); await openPanel(el); const frame = el.shadowRoot!.querySelector('.expanding-action__frame')!; expect(Math.round(frame.getBoundingClientRect().height)).to.equal(250); }); }); });