import { expect, fixture, html } from '@open-wc/testing';
import './nile-button-toggle-group';
import '../nile-button-toggle/nile-button-toggle';
import type { NileButtonToggleGroup } from './nile-button-toggle-group';
import type { NileButtonToggle } from '../nile-button-toggle/nile-button-toggle';
describe('NileButtonToggleGroup', () => {
it('1. renders', async () => { const el = await fixture(html`A`); expect(el).to.exist; });
it('2. shadow root', async () => { const el = await fixture(html`A`); expect(el.shadowRoot).to.not.be.null; });
it('3. tag name', async () => { const el = await fixture(html`A`); expect(el.tagName.toLowerCase()).to.equal('nile-button-toggle-group'); });
it('4. disabled defaults false', async () => { const el = await fixture(html`A`); expect(el.disabled).to.be.false; });
it('5. multiple defaults false', async () => { const el = await fixture(html`A`); expect(el.multiple).to.be.false; });
it('6. disableUserInput defaults false', async () => { const el = await fixture(html`A`); expect(el.disableUserInput).to.be.false; });
it('7. emptyDefault defaults false', async () => { const el = await fixture(html`A`); expect(el.emptyDefault).to.be.false; });
it('8. default slot', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('slot')).to.exist; });
it('9. auto-selects first toggle', async () => { const el = await fixture(html`AB`); expect(el.value).to.equal('a'); });
it('10. sets initial on first toggle', async () => { const el = await fixture(html`AB`); const first = el.querySelector('nile-button-toggle') as NileButtonToggle; expect(first.initial).to.be.true; });
it('11. sets end on last toggle', async () => { const el = await fixture(html`AB`); const toggles = el.querySelectorAll('nile-button-toggle'); const last = toggles[toggles.length - 1] as NileButtonToggle; expect(last.end).to.be.true; });
it('12. sets middle on middle toggle', async () => { const el = await fixture(html`ABC`); const toggles = el.querySelectorAll('nile-button-toggle'); const mid = toggles[1] as NileButtonToggle; expect(mid.middle).to.be.true; });
it('13. set disabled', async () => { const el = await fixture(html`A`); expect(el.disabled).to.be.true; });
it('14. multiple mode', async () => { const el = await fixture(html`A`); expect(el.multiple).to.be.true; });
it('15. multiple value is array', async () => { const el = await fixture(html`A`); expect(Array.isArray(el.value)).to.be.true; });
it('16. emptyDefault no selection', async () => { const el = await fixture(html`A`); expect(el.value).to.equal(''); });
it('17. has styles', async () => { expect((await import('./nile-button-toggle-group')).NileButtonToggleGroup.styles).to.exist; });
it('18. is defined', async () => { expect(customElements.get('nile-button-toggle-group')).to.exist; });
it('19. shadow mode', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.mode).to.equal('open'); });
it('20. isConnected', async () => { const el = await fixture(html`A`); expect(el.isConnected).to.be.true; });
it('21. removal', async () => { const el = await fixture(html`A`); el.remove(); expect(el.isConnected).to.be.false; });
it('22. disabled reflects', async () => { const el = await fixture(html`A`); expect(el.hasAttribute('disabled')).to.be.true; });
it('23. updateComplete', async () => { const el = await fixture(html`A`); const r = await el.updateComplete; expect(r).to.not.be.undefined; });
it('24. render method', async () => { const el = await fixture(html`A`); expect(el.render).to.be.a('function'); });
it('25. shadowRoot host', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.host).to.equal(el); });
it('26. class attr', async () => { const el = await fixture(html`A`); expect(el.classList.contains('bg')).to.be.true; });
it('27. id attr', async () => { const el = await fixture(html`A`); expect(el.id).to.equal('bg1'); });
it('28. hidden', async () => { const el = await fixture(html`A`); expect(el.hidden).to.be.true; });
it('29. nodeType', async () => { const el = await fixture(html`A`); expect(el.nodeType).to.equal(1); });
it('30. localName', async () => { const el = await fixture(html`A`); expect(el.localName).to.equal('nile-button-toggle-group'); });
it('31. namespaceURI', async () => { const el = await fixture(html`A`); expect(el.namespaceURI).to.equal('http://www.w3.org/1999/xhtml'); });
it('32. ownerDocument', async () => { const el = await fixture(html`A`); expect(el.ownerDocument).to.equal(document); });
it('33. outerHTML', async () => { const el = await fixture(html`A`); expect(el.outerHTML).to.contain('nile-button-toggle-group'); });
it('34. matches', async () => { const el = await fixture(html`A`); expect(el.matches('.x')).to.be.true; });
it('35. closest', async () => { const el = await fixture(html`A`); expect(el.closest('nile-button-toggle-group')).to.equal(el); });
it('36. cloneNode', async () => { const el = await fixture(html`A`); expect((el.cloneNode(true) as Element).tagName.toLowerCase()).to.equal('nile-button-toggle-group'); });
it('37. dispatchEvent', async () => { const el = await fixture(html`A`); let f = false; el.addEventListener('c', () => (f = true)); el.dispatchEvent(new Event('c')); expect(f).to.be.true; });
it('38. handleToggle method', async () => { const el = await fixture(html`A`); expect(el.handleToggle).to.be.a('function'); });
it('39. setValue method', async () => { const el = await fixture(html`AB`); el.setValue('b'); await el.updateComplete; expect(el.value).to.equal('b'); });
it('40. setBtnState method', async () => { const el = await fixture(html`A`); expect(el.setBtnState).to.be.a('function'); });
it('41. dataset', async () => { const el = await fixture(html`A`); expect(el.dataset.idx).to.equal('0'); });
it('42. classList add', async () => { const el = await fixture(html`A`); el.classList.add('z'); expect(el.classList.contains('z')).to.be.true; });
it('43. getBoundingClientRect', async () => { const el = await fixture(html`A`); expect(el.getBoundingClientRect()).to.exist; });
it('44. no form', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('form')).to.be.null; });
it('45. no input', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('input')).to.be.null; });
it('46. no button', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('button')).to.be.null; });
it('47. style attr', async () => { const el = await fixture(html`A`); expect(el.style.color).to.equal('red'); });
it('48. data attr', async () => { const el = await fixture(html`A`); expect(el.getAttribute('data-x')).to.equal('1'); });
it('49. childElementCount', async () => { const el = await fixture(html`AB`); expect(el.childElementCount).to.equal(2); });
it('50. requestUpdate', async () => { const el = await fixture(html`A`); el.requestUpdate(); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; });
it('51. shadow childNodes', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.childNodes.length).to.be.greaterThan(0); });
it('52. scrollIntoView', async () => { const el = await fixture(html`A`); expect(el.scrollIntoView).to.be.a('function'); });
it('53. focus method', async () => { const el = await fixture(html`A`); expect(el.focus).to.be.a('function'); });
it('54. blur method', async () => { const el = await fixture(html`A`); expect(el.blur).to.be.a('function'); });
it('55. no anchor', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('a')).to.be.null; });
it('56. no img', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('img')).to.be.null; });
it('57. no svg', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('svg')).to.be.null; });
it('58. createElement', async () => { const el = document.createElement('nile-button-toggle-group') as NileButtonToggleGroup; document.body.appendChild(el); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; document.body.removeChild(el); });
it('59. multiple instances', async () => { const c = await fixture(html`AB
`); expect(c.querySelectorAll('nile-button-toggle-group').length).to.equal(2); });
it('60. parent-child', async () => { const c = await fixture(html`A
`); expect(c.querySelector('nile-button-toggle-group')!.parentElement).to.equal(c); });
it('61. aria-label', async () => { const el = await fixture(html`A`); expect(el.getAttribute('aria-label')).to.equal('Toggle Group'); });
it('62. role', async () => { const el = await fixture(html`A`); expect(el.getAttribute('role')).to.equal('group'); });
it('63. dir', async () => { const el = await fixture(html`A`); expect(el.dir).to.equal('rtl'); });
it('64. title attr', async () => { const el = await fixture(html`A`); expect(el.title).to.equal('TG'); });
it('65. lang attr', async () => { const el = await fixture(html`A`); expect(el.lang).to.equal('en'); });
it('66. tabindex', async () => { const el = await fixture(html`A`); expect(el.getAttribute('tabindex')).to.equal('0'); });
it('67. class toggle', async () => { const el = await fixture(html`A`); el.classList.toggle('a'); expect(el.classList.contains('a')).to.be.true; });
it('68. toggle hidden', async () => { const el = await fixture(html`A`); el.hidden = true; expect(el.hidden).to.be.true; });
it('69. no table', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('table')).to.be.null; });
it('70. no ul', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('ul')).to.be.null; });
it('71. no canvas', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('canvas')).to.be.null; });
it('72. no video', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('video')).to.be.null; });
it('73. no audio', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('audio')).to.be.null; });
it('74. no nav', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('nav')).to.be.null; });
it('75. no aside', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('aside')).to.be.null; });
it('76. no textarea', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('textarea')).to.be.null; });
it('77. no select', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('select')).to.be.null; });
it('78. setAttribute data', async () => { const el = await fixture(html`A`); el.setAttribute('data-x', '1'); expect(el.dataset.x).to.equal('1'); });
it('79. removeAttribute hidden', async () => { const el = await fixture(html`A`); el.removeAttribute('hidden'); expect(el.hidden).to.be.false; });
it('80. hasAttribute id', async () => { const el = await fixture(html`A`); expect(el.hasAttribute('id')).to.be.true; });
it('81. dispatchCustomEvent', async () => { const el = await fixture(html`A`); 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('82. nested in div', async () => { const c = await fixture(html`A
`); expect(c.querySelector('nile-button-toggle-group')).to.exist; });
it('83. active toggle has active prop', async () => { const el = await fixture(html`AB`); const first = el.querySelector('nile-button-toggle') as NileButtonToggle; expect(first.active).to.be.true; });
it('84. value change updates active', async () => { const el = await fixture(html`AB`); el.value = 'b'; await el.updateComplete; const toggles = el.querySelectorAll('nile-button-toggle'); expect((toggles[1] as NileButtonToggle).active).to.be.true; });
it('85. three toggles positions', async () => { const el = await fixture(html`ABC`); const toggles = el.querySelectorAll('nile-button-toggle'); expect((toggles[0] as NileButtonToggle).initial).to.be.true; expect((toggles[1] as NileButtonToggle).middle).to.be.true; expect((toggles[2] as NileButtonToggle).end).to.be.true; });
it('86. aria-describedby', async () => { const el = await fixture(html`A`); expect(el.getAttribute('aria-describedby')).to.equal('d'); });
it('87. multiple re-renders', async () => { const el = await fixture(html`A`); for (let i = 0; i < 3; i++) { el.requestUpdate(); await el.updateComplete; } expect(el.shadowRoot).to.not.be.null; });
it('88. contains', async () => { const el = await fixture(html`A`); expect(el.contains(el.querySelector('nile-button-toggle'))).to.be.true; });
it('89. no h1', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('h1')).to.be.null; });
it('90. no p', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('p')).to.be.null; });
it('91. no hr', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('hr')).to.be.null; });
it('92. no nile-icon', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('nile-icon')).to.be.null; });
it('93. no pre', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('pre')).to.be.null; });
it('94. no code', async () => { const el = await fixture(html`A`); expect(el.shadowRoot!.querySelector('code')).to.be.null; });
it('95. setAttribute class', async () => { const el = await fixture(html`A`); el.setAttribute('class', 'test'); expect(el.classList.contains('test')).to.be.true; });
it('96. removeAttribute class', async () => { const el = await fixture(html`A`); el.removeAttribute('class'); expect(el.classList.contains('x')).to.be.false; });
it('97. single toggle positions', async () => { const el = await fixture(html`A`); const t = el.querySelector('nile-button-toggle') as NileButtonToggle; expect(t.initial).to.be.true; expect(t.end).to.be.true; });
it('98. firstElementChild', async () => { const el = await fixture(html`A`); expect(el.firstElementChild!.tagName.toLowerCase()).to.equal('nile-button-toggle'); });
it('99. updateTogglePositions method', async () => { const el = await fixture(html`A`); expect(el.updateTogglePositions).to.be.a('function'); });
it('100. full integration', async () => { const el = await fixture(html`ABC`); expect(el.id).to.equal('bg1'); expect(el.childElementCount).to.equal(3); expect(el.value).to.equal('a'); const toggles = el.querySelectorAll('nile-button-toggle'); expect((toggles[0] as NileButtonToggle).active).to.be.true; expect((toggles[0] as NileButtonToggle).initial).to.be.true; expect((toggles[2] as NileButtonToggle).end).to.be.true; });
});