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