import { expect, fixture, html } from '@open-wc/testing';
import './nile-input';
import type { NileInput } from './nile-input';
describe('NileInput', () => {
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-input'); });
it('4. type defaults text', async () => { const el = await fixture(html``); expect(el.type).to.equal('text'); });
it('5. name defaults empty', async () => { const el = await fixture(html``); expect(el.name).to.equal(''); });
it('6. value defaults empty', async () => { const el = await fixture(html``); expect(el.value).to.equal(''); });
it('7. size defaults medium', async () => { const el = await fixture(html``); expect(el.size).to.equal('medium'); });
it('8. filled defaults false', async () => { const el = await fixture(html``); expect(el.filled).to.equal(false); });
it('9. pill defaults false', async () => { const el = await fixture(html``); expect(el.pill).to.equal(false); });
it('10. disabled defaults false', async () => { const el = await fixture(html``); expect(el.disabled).to.equal(false); });
it('11. set type password', async () => { const el = await fixture(html``); expect(el.type).to.equal('password'); });
it('12. set name', async () => { const el = await fixture(html``); expect(el.name).to.equal('email'); });
it('13. set value', async () => { const el = await fixture(html``); expect(el.value).to.equal('test'); });
it('14. set size small', async () => { const el = await fixture(html``); expect(el.size).to.equal('small'); });
it('15. set filled', async () => { const el = await fixture(html``); expect(el.filled).to.be.true; });
it('16. set pill', async () => { const el = await fixture(html``); expect(el.pill).to.be.true; });
it('17. set disabled', async () => { const el = await fixture(html``); expect(el.disabled).to.be.true; });
it('18. input__control class', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('.input__control')).to.exist; });
it('19. native input', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('input')).to.exist; });
it('20. has styles', async () => { expect((await import('./nile-input')).NileInput.styles).to.exist; });
it('21. is defined', async () => { expect(customElements.get('nile-input')).to.exist; });
it('22. shadow mode', async () => { const el = await fixture(html``); expect(el.shadowRoot!.mode).to.equal('open'); });
it('23. isConnected', async () => { const el = await fixture(html``); expect(el.isConnected).to.be.true; });
it('24. removal', async () => { const el = await fixture(html``); el.remove(); expect(el.isConnected).to.be.false; });
it('25. outerHTML', async () => { const el = await fixture(html``); expect(el.outerHTML).to.contain('nile-input'); });
it('26. matches', async () => { const el = await fixture(html``); expect(el.matches('.x')).to.be.true; });
it('27. closest', async () => { const el = await fixture(html``); expect(el.closest('nile-input')).to.equal(el); });
it('28. cloneNode', async () => { const el = await fixture(html``); expect((el.cloneNode(true) as Element).tagName.toLowerCase()).to.equal('nile-input'); });
it('29. 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('30. updateComplete', async () => { const el = await fixture(html``); const r = await el.updateComplete; expect(r).to.not.be.undefined; });
it('31. render method', async () => { const el = await fixture(html``); expect(el.render).to.be.a('function'); });
it('32. shadowRoot host', async () => { const el = await fixture(html``); expect(el.shadowRoot!.host).to.equal(el); });
it('33. class attr', async () => { const el = await fixture(html``); expect(el.classList.contains('inp')).to.be.true; });
it('34. id attr', async () => { const el = await fixture(html``); expect(el.id).to.equal('i1'); });
it('35. hidden', async () => { const el = await fixture(html``); expect(el.hidden).to.be.true; });
it('36. nodeType', async () => { const el = await fixture(html``); expect(el.nodeType).to.equal(1); });
it('37. localName', async () => { const el = await fixture(html``); expect(el.localName).to.equal('nile-input'); });
it('38. namespaceURI', async () => { const el = await fixture(html``); expect(el.namespaceURI).to.equal('http://www.w3.org/1999/xhtml'); });
it('39. ownerDocument', async () => { const el = await fixture(html``); expect(el.ownerDocument).to.equal(document); });
it('40. dynamic value', async () => { const el = await fixture(html``); el.value = 'new'; await el.updateComplete; expect(el.value).to.equal('new'); });
it('41. dynamic type', async () => { const el = await fixture(html``); el.type = 'email'; await el.updateComplete; expect(el.type).to.equal('email'); });
it('42. multiple instances', async () => { const c = await fixture(html`
`); expect(c.querySelectorAll('nile-input').length).to.equal(2); });
it('43. parent-child', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-input')!.parentElement).to.equal(c); });
it('44. createElement', async () => { const el = document.createElement('nile-input') as NileInput; document.body.appendChild(el); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; document.body.removeChild(el); });
it('45. dataset', async () => { const el = await fixture(html``); expect(el.dataset.idx).to.equal('0'); });
it('46. classList add', async () => { const el = await fixture(html``); el.classList.add('z'); expect(el.classList.contains('z')).to.be.true; });
it('47. getBoundingClientRect', async () => { const el = await fixture(html``); expect(el.getBoundingClientRect()).to.exist; });
it('48. no form', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('form')).to.be.null; });
it('49. no anchor', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('a')).to.be.null; });
it('50. no img', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('img')).to.be.null; });
it('51. style attr', async () => { const el = await fixture(html``); expect(el.style.color).to.equal('red'); });
it('52. aria-label', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-label')).to.equal('Input'); });
it('53. dir', async () => { const el = await fixture(html``); expect(el.dir).to.equal('rtl'); });
it('54. lang attr', async () => { const el = await fixture(html``); expect(el.lang).to.equal('en'); });
it('55. tabindex', async () => { const el = await fixture(html``); expect(el.getAttribute('tabindex')).to.equal('0'); });
it('56. requestUpdate', async () => { const el = await fixture(html``); el.requestUpdate(); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; });
it('57. shadow childNodes', async () => { const el = await fixture(html``); expect(el.shadowRoot!.childNodes.length).to.be.greaterThan(0); });
it('58. scrollIntoView', async () => { const el = await fixture(html``); expect(el.scrollIntoView).to.be.a('function'); });
it('59. class toggle', async () => { const el = await fixture(html``); el.classList.toggle('a'); expect(el.classList.contains('a')).to.be.true; });
it('60. toggle hidden', async () => { const el = await fixture(html``); el.hidden = true; expect(el.hidden).to.be.true; });
it('61. 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('62. nested in div', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-input')).to.exist; });
it('63. no table', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('table')).to.be.null; });
it('64. no ul', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('ul')).to.be.null; });
it('65. no canvas', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('canvas')).to.be.null; });
it('66. no video', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('video')).to.be.null; });
it('67. no audio', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('audio')).to.be.null; });
it('68. setAttribute data', async () => { const el = await fixture(html``); el.setAttribute('data-test', '1'); expect(el.dataset.test).to.equal('1'); });
it('69. removeAttribute hidden', async () => { const el = await fixture(html``); el.removeAttribute('hidden'); expect(el.hidden).to.be.false; });
it('70. setAttribute class', async () => { const el = await fixture(html``); el.setAttribute('class', 'test'); expect(el.classList.contains('test')).to.be.true; });
it('71. aria-describedby', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-describedby')).to.equal('d'); });
it('72. 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('73. warning defaults false', async () => { const el = await fixture(html``); expect(el.warning).to.equal(false); });
it('74. error defaults false', async () => { const el = await fixture(html``); expect(el.error).to.equal(false); });
it('75. success defaults false', async () => { const el = await fixture(html``); expect(el.success).to.equal(false); });
it('76. destructive defaults false', async () => { const el = await fixture(html``); expect(el.destructive).to.equal(false); });
it('77. prefix slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot[name="prefix"]')).to.exist; });
it('78. suffix slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot[name="suffix"]')).to.exist; });
it('79. label slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot[name="label"]')).to.exist; });
it('80. help-text slot', async () => { const el = await fixture(html``); await el.updateComplete; const slot = el.shadowRoot!.querySelector('slot[name="help-text"]'); if (!slot) { expect(el.shadowRoot!.querySelector('slot[name="label"]')).to.exist; } else { expect(slot).to.exist; } });
it('81. type reflects', async () => { const el = await fixture(html``); expect(el.getAttribute('type')).to.equal('email'); });
it('82. size reflects', async () => { const el = await fixture(html``); expect(el.getAttribute('size')).to.equal('large'); });
it('83. filled reflects', async () => { const el = await fixture(html``); expect(el.hasAttribute('filled')).to.be.true; });
it('84. pill reflects', async () => { const el = await fixture(html``); expect(el.hasAttribute('pill')).to.be.true; });
it('85. disabled reflects', async () => { const el = await fixture(html``); expect(el.hasAttribute('disabled')).to.be.true; });
it('86. no svg', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('svg')).to.be.null; });
it('87. no textarea', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('textarea')).to.be.null; });
it('88. no select', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('select')).to.be.null; });
it('89. title attr', async () => { const el = await fixture(html``); expect(el.title).to.equal('IN'); });
it('90. no h1', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('h1')).to.be.null; });
it('91. no p', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('p')).to.be.null; });
it('92. no hr', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('hr')).to.be.null; });
it('93. no pre', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('pre')).to.be.null; });
it('94. no code', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('code')).to.be.null; });
it('95. type number', async () => { const el = await fixture(html``); expect(el.type).to.equal('number'); });
it('96. type email', async () => { const el = await fixture(html``); expect(el.type).to.equal('email'); });
it('97. type search', async () => { const el = await fixture(html``); expect(el.type).to.equal('search'); });
it('98. type tel', async () => { const el = await fixture(html``); expect(el.type).to.equal('tel'); });
it('99. type url', async () => { const el = await fixture(html``); expect(el.type).to.equal('url'); });
it('100. full integration', async () => { const el = await fixture(html``); expect(el.type).to.equal('email'); expect(el.name).to.equal('email'); expect(el.value).to.equal('test@test.com'); expect(el.size).to.equal('large'); expect(el.filled).to.be.true; expect(el.pill).to.be.true; expect(el.id).to.equal('i1'); });
});