import { expect, fixture, html } from '@open-wc/testing'; import './nile-command-menu-item'; import type { NileCommandMenuItem } from './nile-command-menu-item'; describe('NileCommandMenuItem', () => { it('1. renders', async () => { const el = await fixture(html``); expect(el).to.exist; }); it('2. shadow root', async () => { const el = await fixture(html``); expect(el.shadowRoot).to.not.be.null; }); it('3. tag name', async () => { const el = await fixture(html``); expect(el.tagName.toLowerCase()).to.equal('nile-command-menu-item'); }); it('4. size defaults small', async () => { const el = await fixture(html``); expect(el.size).to.equal('small'); }); it('5. value defaults empty', async () => { const el = await fixture(html``); expect(el.value).to.equal(''); }); it('6. disabled defaults false', async () => { const el = await fixture(html``); expect(el.disabled).to.be.false; }); it('7. active defaults false', async () => { const el = await fixture(html``); expect(el.active).to.be.false; }); it('8. keywords defaults empty', async () => { const el = await fixture(html``); expect(el.keywords).to.equal(''); }); it('9. shortcut defaults empty', async () => { const el = await fixture(html``); expect(el.shortcut).to.equal(''); }); it('10. set size medium', async () => { const el = await fixture(html``); expect(el.size).to.equal('medium'); }); it('11. set value', async () => { const el = await fixture(html``); expect(el.value).to.equal('open'); }); it('12. set disabled', async () => { const el = await fixture(html``); expect(el.disabled).to.be.true; }); it('13. role option', async () => { const el = await fixture(html``); expect(el.getAttribute('role')).to.equal('option'); }); it('14. base part', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="base"]')).to.exist; }); it('15. label part', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="label"]')).to.exist; }); it('16. icon slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot[name="icon"]')).to.exist; }); it('17. suffix slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot[name="suffix"]')).to.exist; }); it('18. default slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot:not([name])')).to.exist; }); it('19. aria-disabled reflects', async () => { const el = await fixture(html``); await el.updateComplete; expect(el.getAttribute('aria-disabled')).to.equal('true'); }); it('20. aria-selected reflects', async () => { const el = await fixture(html``); await el.updateComplete; expect(el.getAttribute('aria-selected')).to.equal('true'); }); it('21. shortcut renders kbd', async () => { const el = await fixture(html``); await el.updateComplete; expect(el.shadowRoot!.querySelectorAll('kbd').length).to.equal(2); }); it('22. no shortcut no kbd', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('kbd')).to.be.null; }); it('23. getTextLabel', async () => { const el = await fixture(html`Open file`); expect(el.getTextLabel().trim()).to.equal('Open file'); }); it('24. getFilterText includes label', async () => { const el = await fixture(html`Open file`); expect(el.getFilterText()).to.contain('open file'); }); it('25. getFilterText includes keywords', async () => { const el = await fixture(html`File`); expect(el.getFilterText()).to.contain('document'); }); it('26. getFilterText includes value', async () => { const el = await fixture(html`File`); expect(el.getFilterText()).to.contain('cmd-open'); }); it('27. disabled click swallowed', async () => { const el = await fixture(html`X`); let fired = false; el.addEventListener('click', () => (fired = true)); el.click(); expect(fired).to.be.false; }); it('28. enabled click bubbles', async () => { const el = await fixture(html`X`); let fired = false; el.addEventListener('click', () => (fired = true)); el.click(); expect(fired).to.be.true; }); it('29. dynamic active', async () => { const el = await fixture(html``); el.active = true; await el.updateComplete; expect(el.getAttribute('aria-selected')).to.equal('true'); }); it('30. is defined', async () => { expect(customElements.get('nile-command-menu-item')).to.exist; }); });