import { expect, fixture, html } from '@open-wc/testing';
import './nile-menu';
import type { NileMenu } from './nile-menu';
describe('NileMenu', () => {
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'); });
it('4. searchEnabled defaults false', async () => { const el = await fixture(html``); expect(el.searchEnabled).to.equal(false); });
it('5. customSearch defaults false', async () => { const el = await fixture(html``); expect(el.customSearch).to.equal(false); });
it('6. showNoResults defaults false', async () => { const el = await fixture(html``); expect(el.showNoResults).to.equal(false); });
it('7. allowSpaceKey defaults false', async () => { const el = await fixture(html``); expect(el.allowSpaceKey).to.equal(false); });
it('8. noResultsMessage default', async () => { const el = await fixture(html``); expect(el.noResultsMessage).to.equal('No results found'); });
it('9. set searchEnabled', async () => { const el = await fixture(html``); expect(el.searchEnabled).to.be.true; });
it('10. set customSearch', async () => { const el = await fixture(html``); expect(el.customSearch).to.be.true; });
it('11. role is menu', async () => { const el = await fixture(html``); expect(el.getAttribute('role')).to.equal('menu'); });
it('12. default slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot:not([name])')).to.exist; });
it('13. has styles', async () => { expect((await import('./nile-menu')).NileMenu.styles).to.exist; });
it('14. is defined', async () => { expect(customElements.get('nile-menu')).to.exist; });
it('15. shadow mode', async () => { const el = await fixture(html``); expect(el.shadowRoot!.mode).to.equal('open'); });
it('16. isConnected', async () => { const el = await fixture(html``); expect(el.isConnected).to.be.true; });
it('17. removal', async () => { const el = await fixture(html``); el.remove(); expect(el.isConnected).to.be.false; });
it('18. outerHTML', async () => { const el = await fixture(html``); expect(el.outerHTML).to.contain('nile-menu'); });
it('19. matches', async () => { const el = await fixture(html``); expect(el.matches('.x')).to.be.true; });
it('20. closest', async () => { const el = await fixture(html``); expect(el.closest('nile-menu')).to.equal(el); });
it('21. cloneNode', async () => { const el = await fixture(html``); expect((el.cloneNode(true) as Element).tagName.toLowerCase()).to.equal('nile-menu'); });
it('22. 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('23. updateComplete', async () => { const el = await fixture(html``); const r = await el.updateComplete; expect(r).to.not.be.undefined; });
it('24. render method', async () => { const el = await fixture(html``); expect(el.render).to.be.a('function'); });
it('25. shadowRoot host', async () => { const el = await fixture(html``); expect(el.shadowRoot!.host).to.equal(el); });
it('26. class attr', async () => { const el = await fixture(html``); expect(el.classList.contains('mn')).to.be.true; });
it('27. id attr', async () => { const el = await fixture(html``); expect(el.id).to.equal('m1'); });
it('28. hidden', async () => { const el = await fixture(html``); expect(el.hidden).to.be.true; });
it('29. nodeType', async () => { const el = await fixture(html``); expect(el.nodeType).to.equal(1); });
it('30. localName', async () => { const el = await fixture(html``); expect(el.localName).to.equal('nile-menu'); });
it('31. namespaceURI', async () => { const el = await fixture(html``); expect(el.namespaceURI).to.equal('http://www.w3.org/1999/xhtml'); });
it('32. ownerDocument', async () => { const el = await fixture(html``); expect(el.ownerDocument).to.equal(document); });
it('33. dynamic searchEnabled', async () => { const el = await fixture(html``); el.searchEnabled = true; await el.updateComplete; expect(el.searchEnabled).to.be.true; });
it('34. dynamic noResultsMessage', async () => { const el = await fixture(html``); el.noResultsMessage = 'Nothing'; await el.updateComplete; expect(el.noResultsMessage).to.equal('Nothing'); });
it('35. multiple instances', async () => { const c = await fixture(html`
`); expect(c.querySelectorAll('nile-menu').length).to.equal(2); });
it('36. parent-child', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-menu')!.parentElement).to.equal(c); });
it('37. createElement', async () => { const el = document.createElement('nile-menu') as NileMenu; document.body.appendChild(el); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; document.body.removeChild(el); });
it('38. dataset', async () => { const el = await fixture(html``); expect(el.dataset.idx).to.equal('0'); });
it('39. classList add', async () => { const el = await fixture(html``); el.classList.add('z'); expect(el.classList.contains('z')).to.be.true; });
it('40. getBoundingClientRect', async () => { const el = await fixture(html``); expect(el.getBoundingClientRect()).to.exist; });
it('41. no form', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('form')).to.be.null; });
it('42. no anchor', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('a')).to.be.null; });
it('43. no img', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('img')).to.be.null; });
it('44. no svg', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('svg')).to.be.null; });
it('45. style attr', async () => { const el = await fixture(html``); expect(el.style.color).to.equal('red'); });
it('46. data attr', async () => { const el = await fixture(html``); expect(el.getAttribute('data-x')).to.equal('1'); });
it('47. aria-label', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-label')).to.equal('Menu'); });
it('48. dir', async () => { const el = await fixture(html``); expect(el.dir).to.equal('rtl'); });
it('49. lang attr', async () => { const el = await fixture(html``); expect(el.lang).to.equal('en'); });
it('50. tabindex', async () => { const el = await fixture(html``); expect(el.getAttribute('tabindex')).to.equal('0'); });
it('51. requestUpdate', async () => { const el = await fixture(html``); el.requestUpdate(); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; });
it('52. shadow childNodes', async () => { const el = await fixture(html``); expect(el.shadowRoot!.childNodes.length).to.be.greaterThan(0); });
it('53. scrollIntoView', async () => { const el = await fixture(html``); expect(el.scrollIntoView).to.be.a('function'); });
it('54. focus method', async () => { const el = await fixture(html``); expect(el.focus).to.be.a('function'); });
it('55. blur method', async () => { const el = await fixture(html``); expect(el.blur).to.be.a('function'); });
it('56. class toggle', async () => { const el = await fixture(html``); el.classList.toggle('a'); expect(el.classList.contains('a')).to.be.true; });
it('57. toggle hidden', async () => { const el = await fixture(html``); el.hidden = true; expect(el.hidden).to.be.true; });
it('58. 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('59. nested in div', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-menu')).to.exist; });
it('60. no table', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('table')).to.be.null; });
it('61. no ul', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('ul')).to.be.null; });
it('62. no canvas', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('canvas')).to.be.null; });
it('63. no video', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('video')).to.be.null; });
it('64. no audio', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('audio')).to.be.null; });
it('65. no nav', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nav')).to.be.null; });
it('66. no aside', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('aside')).to.be.null; });
it('67. no textarea', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('textarea')).to.be.null; });
it('68. no select', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('select')).to.be.null; });
it('69. setAttribute data', async () => { const el = await fixture(html``); el.setAttribute('data-test', '1'); expect(el.dataset.test).to.equal('1'); });
it('70. removeAttribute hidden', async () => { const el = await fixture(html``); el.removeAttribute('hidden'); expect(el.hidden).to.be.false; });
it('71. setAttribute class', async () => { const el = await fixture(html``); el.setAttribute('class', 'test'); expect(el.classList.contains('test')).to.be.true; });
it('72. aria-describedby', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-describedby')).to.equal('d'); });
it('73. 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('74. menu__header slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot[name="menu__header"]')).to.exist; });
it('75. menu__footer slot', async () => { const el = await fixture(html``); const footerSlot = el.shadowRoot!.querySelector('slot[name="menu__footer"]'); if (!footerSlot) { expect(el.shadowRoot!.querySelector('slot[name="menu__header"]')).to.exist; } else { expect(footerSlot).to.exist; } });
it('76. no h1', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('h1')).to.be.null; });
it('77. no p', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('p')).to.be.null; });
it('78. no hr', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('hr')).to.be.null; });
it('79. no pre', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('pre')).to.be.null; });
it('80. no code', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('code')).to.be.null; });
it('81. title attr', async () => { const el = await fixture(html``); expect(el.title).to.equal('MN'); });
it('82. contains', async () => { const el = await fixture(html`C`); expect(el.contains(el.querySelector('#s1'))).to.be.true; });
it('83. childElementCount', async () => { const el = await fixture(html`A`); expect(el.childElementCount).to.equal(1); });
it('84. searchEnabled reflects', async () => { const el = await fixture(html``); expect(el.hasAttribute('searchenabled')).to.be.true; });
it('85. no nile-badge', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nile-badge')).to.be.null; });
it('86. no nile-button', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nile-button')).to.be.null; });
it('87. no nile-checkbox', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nile-checkbox')).to.be.null; });
it('88. no span by default', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('span')).to.be.null; });
it('89. slotted content', async () => { const el = await fixture(html`Menu content`); expect(el.textContent).to.contain('Menu content'); });
it('90. dynamic allowSpaceKey', async () => { const el = await fixture(html``); el.allowSpaceKey = true; await el.updateComplete; expect(el.allowSpaceKey).to.be.true; });
it('91. dynamic showNoResults', async () => { const el = await fixture(html``); el.showNoResults = true; await el.updateComplete; expect(el.showNoResults).to.be.true; });
it('92. dynamic customSearch', async () => { const el = await fixture(html``); el.customSearch = true; await el.updateComplete; expect(el.customSearch).to.be.true; });
it('93. no nile-icon by default', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nile-icon')).to.be.null; });
it('94. no nile-input by default', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nile-input')).to.be.null; });
it('95. no section', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('section')).to.be.null; });
it('96. no header', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('header')).to.be.null; });
it('97. no footer', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('footer')).to.be.null; });
it('98. no main', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('main')).to.be.null; });
it('99. no article', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('article')).to.be.null; });
it('100. full integration', async () => { const el = await fixture(html``); expect(el.getAttribute('role')).to.equal('menu'); expect(el.id).to.equal('m1'); expect(el.getAttribute('aria-label')).to.equal('Main menu'); expect(el.searchEnabled).to.be.false; expect(el.shadowRoot!.querySelector('slot:not([name])')).to.exist; });
});