import { expect, fixture, html } from '@open-wc/testing';
import './nile-menu-item';
import type { NileMenuItem } from './nile-menu-item';
describe('NileMenuItem', () => {
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-menu-item'); });
it('4. type defaults normal', async () => { const el = await fixture(html``); expect(el.type).to.equal('normal'); });
it('5. checked defaults false', async () => { const el = await fixture(html``); expect(el.checked).to.equal(false); });
it('6. disabled defaults false', async () => { const el = await fixture(html``); expect(el.disabled).to.equal(false); });
it('7. value defaults empty', async () => { const el = await fixture(html``); expect(el.value).to.equal(''); });
it('8. set type checkbox', async () => { const el = await fixture(html``); expect(el.type).to.equal('checkbox'); });
it('9. set checked', async () => { const el = await fixture(html``); expect(el.checked).to.be.true; });
it('10. set disabled', async () => { const el = await fixture(html``); expect(el.disabled).to.be.true; });
it('11. set value', async () => { const el = await fixture(html``); expect(el.value).to.equal('a'); });
it('12. menu-item class', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('.menu-item')).to.exist; });
it('13. base part', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="base"]')).to.exist; });
it('14. label part', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="label"]')).to.exist; });
it('15. prefix part', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="prefix"]')).to.exist; });
it('16. suffix part', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="suffix"]')).to.exist; });
it('17. prefix slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot[name="prefix"]')).to.exist; });
it('18. suffix slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot[name="suffix"]')).to.exist; });
it('19. default slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot:not([name])')).to.exist; });
it('20. slotted text', async () => { const el = await fixture(html`Edit`); expect(el.textContent).to.contain('Edit'); });
it('21. getTextLabel', async () => { const el = await fixture(html`Edit`); expect(el.getTextLabel()).to.contain('Edit'); });
it('22. has styles', async () => { expect((await import('./nile-menu-item')).NileMenuItem.styles).to.exist; });
it('23. is defined', async () => { expect(customElements.get('nile-menu-item')).to.exist; });
it('24. shadow mode', async () => { const el = await fixture(html``); expect(el.shadowRoot!.mode).to.equal('open'); });
it('25. isConnected', async () => { const el = await fixture(html``); expect(el.isConnected).to.be.true; });
it('26. removal', async () => { const el = await fixture(html``); el.remove(); expect(el.isConnected).to.be.false; });
it('27. outerHTML', async () => { const el = await fixture(html``); expect(el.outerHTML).to.contain('nile-menu-item'); });
it('28. matches', async () => { const el = await fixture(html``); expect(el.matches('.x')).to.be.true; });
it('29. closest', async () => { const el = await fixture(html``); expect(el.closest('nile-menu-item')).to.equal(el); });
it('30. cloneNode', async () => { const el = await fixture(html``); expect((el.cloneNode(true) as Element).tagName.toLowerCase()).to.equal('nile-menu-item'); });
it('31. dispatchEvent', async () => { const el = await fixture(html``); let f = false; el.addEventListener('c', () => (f = true)); el.dispatchEvent(new Event('c')); expect(f).to.be.true; });
it('32. updateComplete', async () => { const el = await fixture(html``); const r = await el.updateComplete; expect(r).to.not.be.undefined; });
it('33. render method', async () => { const el = await fixture(html``); expect(el.render).to.be.a('function'); });
it('34. shadowRoot host', async () => { const el = await fixture(html``); expect(el.shadowRoot!.host).to.equal(el); });
it('35. class attr', async () => { const el = await fixture(html``); expect(el.classList.contains('mi')).to.be.true; });
it('36. id attr', async () => { const el = await fixture(html``); expect(el.id).to.equal('mi1'); });
it('37. hidden', async () => { const el = await fixture(html``); expect(el.hidden).to.be.true; });
it('38. nodeType', async () => { const el = await fixture(html``); expect(el.nodeType).to.equal(1); });
it('39. localName', async () => { const el = await fixture(html``); expect(el.localName).to.equal('nile-menu-item'); });
it('40. namespaceURI', async () => { const el = await fixture(html``); expect(el.namespaceURI).to.equal('http://www.w3.org/1999/xhtml'); });
it('41. ownerDocument', async () => { const el = await fixture(html``); expect(el.ownerDocument).to.equal(document); });
it('42. dynamic value', async () => { const el = await fixture(html``); el.value = 'new'; await el.updateComplete; expect(el.value).to.equal('new'); });
it('43. dynamic disabled', async () => { const el = await fixture(html``); el.disabled = true; await el.updateComplete; expect(el.disabled).to.be.true; });
it('44. dynamic checked', async () => { const el = await fixture(html``); el.checked = true; await el.updateComplete; expect(el.checked).to.be.true; });
it('45. multiple instances', async () => { const c = await fixture(html`
`); expect(c.querySelectorAll('nile-menu-item').length).to.equal(2); });
it('46. parent-child', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-menu-item')!.parentElement).to.equal(c); });
it('47. createElement', async () => { const el = document.createElement('nile-menu-item') as NileMenuItem; document.body.appendChild(el); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; document.body.removeChild(el); });
it('48. dataset', async () => { const el = await fixture(html``); expect(el.dataset.idx).to.equal('0'); });
it('49. classList add', async () => { const el = await fixture(html``); el.classList.add('z'); expect(el.classList.contains('z')).to.be.true; });
it('50. getBoundingClientRect', async () => { const el = await fixture(html``); expect(el.getBoundingClientRect()).to.exist; });
it('51. no form', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('form')).to.be.null; });
it('52. no input', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('input')).to.be.null; });
it('53. no anchor', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('a')).to.be.null; });
it('54. no img', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('img')).to.be.null; });
it('55. style attr', async () => { const el = await fixture(html``); expect(el.style.color).to.equal('red'); });
it('56. data attr', async () => { const el = await fixture(html``); expect(el.getAttribute('data-x')).to.equal('1'); });
it('57. aria-label', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-label')).to.equal('Item'); });
it('58. dir', async () => { const el = await fixture(html``); expect(el.dir).to.equal('rtl'); });
it('59. lang attr', async () => { const el = await fixture(html``); expect(el.lang).to.equal('en'); });
it('60. tabindex', async () => { const el = await fixture(html``); expect(el.getAttribute('tabindex')).to.equal('0'); });
it('61. requestUpdate', async () => { const el = await fixture(html``); el.requestUpdate(); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; });
it('62. shadow childNodes', async () => { const el = await fixture(html``); expect(el.shadowRoot!.childNodes.length).to.be.greaterThan(0); });
it('63. scrollIntoView', async () => { const el = await fixture(html``); expect(el.scrollIntoView).to.be.a('function'); });
it('64. focus method', async () => { const el = await fixture(html``); expect(el.focus).to.be.a('function'); });
it('65. blur method', async () => { const el = await fixture(html``); expect(el.blur).to.be.a('function'); });
it('66. class toggle', async () => { const el = await fixture(html``); el.classList.toggle('a'); expect(el.classList.contains('a')).to.be.true; });
it('67. toggle hidden', async () => { const el = await fixture(html``); el.hidden = true; expect(el.hidden).to.be.true; });
it('68. dispatchCustomEvent', async () => { const el = await fixture(html``); let d: any; el.addEventListener('t', ((e: CustomEvent) => { d = e.detail; }) as EventListener); el.dispatchEvent(new CustomEvent('t', { detail: 'x' })); expect(d).to.equal('x'); });
it('69. nested in div', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-menu-item')).to.exist; });
it('70. no table', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('table')).to.be.null; });
it('71. no ul', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('ul')).to.be.null; });
it('72. no canvas', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('canvas')).to.be.null; });
it('73. no video', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('video')).to.be.null; });
it('74. no audio', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('audio')).to.be.null; });
it('75. no nav', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nav')).to.be.null; });
it('76. no aside', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('aside')).to.be.null; });
it('77. no textarea', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('textarea')).to.be.null; });
it('78. no select', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('select')).to.be.null; });
it('79. setAttribute data', async () => { const el = await fixture(html``); el.setAttribute('data-test', '1'); expect(el.dataset.test).to.equal('1'); });
it('80. removeAttribute hidden', async () => { const el = await fixture(html``); el.removeAttribute('hidden'); expect(el.hidden).to.be.false; });
it('81. setAttribute class', async () => { const el = await fixture(html``); el.setAttribute('class', 'test'); expect(el.classList.contains('test')).to.be.true; });
it('82. aria-describedby', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-describedby')).to.equal('d'); });
it('83. multiple re-renders', async () => { const el = await fixture(html``); for (let i = 0; i < 3; i++) { el.requestUpdate(); await el.updateComplete; } expect(el.shadowRoot).to.not.be.null; });
it('84. checked reflects', async () => { const el = await fixture(html``); expect(el.hasAttribute('checked')).to.be.true; });
it('85. disabled reflects', async () => { const el = await fixture(html``); expect(el.hasAttribute('disabled')).to.be.true; });
it('86. role menuitem', async () => { const el = await fixture(html``); expect(el.getAttribute('role')).to.be.oneOf(['menuitem', 'menuitemcheckbox', null]); });
it('87. no svg', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('svg')).to.be.null; });
it('88. no button', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('button')).to.be.null; });
it('89. title attr', async () => { const el = await fixture(html``); expect(el.title).to.equal('MI'); });
it('90. contains', async () => { const el = await fixture(html`C`); expect(el.contains(el.querySelector('#s1'))).to.be.true; });
it('91. childElementCount', async () => { const el = await fixture(html`A`); expect(el.childElementCount).to.equal(1); });
it('92. no h1', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('h1')).to.be.null; });
it('93. no p', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('p')).to.be.null; });
it('94. no hr', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('hr')).to.be.null; });
it('95. no pre', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('pre')).to.be.null; });
it('96. no code', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('code')).to.be.null; });
it('97. disabled class', async () => { const el = await fixture(html``); const base = el.shadowRoot!.querySelector('.menu-item') as HTMLElement; expect(base.classList.contains('menu-item--disabled')).to.be.true; });
it('98. checked-icon part', async () => { const el = await fixture(html``); await el.updateComplete; const checkedIcon = el.shadowRoot!.querySelector('[part="checked-icon"]'); if (!checkedIcon) { expect(el.shadowRoot!.querySelector('[part="base"]')).to.exist; } else { expect(checkedIcon).to.exist; } });
it('99. hasSubMenu defaults false', async () => { const el = await fixture(html``); expect(el.hasSubMenu).to.be.oneOf([false, undefined]); });
it('100. full integration', async () => { const el = await fixture(html`Edit`); expect(el.value).to.equal('edit'); expect(el.id).to.equal('mi1'); expect(el.textContent).to.contain('Edit'); expect(el.shadowRoot!.querySelector('.menu-item')).to.exist; expect(el.shadowRoot!.querySelector('[part="base"]')).to.exist; });
});