import { expect, fixture, html } from '@open-wc/testing';
import './nile-date-picker';
import type { NileDatePicker } from './nile-date-picker';
describe('NileDatePicker', () => {
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-date-picker'); });
it('4. range defaults false', async () => { const el = await fixture(html``); expect(el.range).to.equal(false); });
it('5. hideTypes defaults false', async () => { const el = await fixture(html``); expect(el.hideTypes).to.equal(false); });
it('6. open defaults false', async () => { const el = await fixture(html``); expect(el.open).to.equal(false); });
it('7. type defaults absolute', async () => { const el = await fixture(html``); expect(el.type).to.equal('absolute'); });
it('8. showManualInputs defaults false', async () => { const el = await fixture(html``); expect(el.showManualInputs).to.equal(false); });
it('9. allowClear defaults false', async () => { const el = await fixture(html``); expect(el.allowClear).to.equal(false); });
it('10. hideTimeZone defaults false', async () => { const el = await fixture(html``); expect(el.hideTimeZone).to.equal(false); });
it('11. doubleClickUnselect defaults false', async () => { const el = await fixture(html``); expect(el.doubleClickUnselect).to.equal(false); });
it('12. dateFormat defaults DD/MM/YYYY', async () => { const el = await fixture(html``); expect(el.dateFormat).to.equal('DD/MM/YYYY'); });
it('13. rangeSeparator defaults " - "', async () => { const el = await fixture(html``); expect(el.rangeSeparator).to.equal(' - '); });
it('14. showYearDropdown defaults false', async () => { const el = await fixture(html``); expect(el.showYearDropdown).to.equal(false); });
it('15. showMonthDropdown defaults false', async () => { const el = await fixture(html``); expect(el.showMonthDropdown).to.equal(false); });
it('16. syncDatePicker defaults false', async () => { const el = await fixture(html``); expect(el.syncDatePicker).to.equal(false); });
it('17. set range', async () => { const el = await fixture(html``); expect(el.range).to.be.true; });
it('18. set type relative', async () => { const el = await fixture(html``); expect(el.type).to.equal('relative'); });
it('19. has styles', async () => { expect((await import('./nile-date-picker')).NileDatePicker.styles).to.exist; });
it('20. is defined', async () => { expect(customElements.get('nile-date-picker')).to.exist; });
it('21. shadow mode', async () => { const el = await fixture(html``); expect(el.shadowRoot!.mode).to.equal('open'); });
it('22. isConnected', async () => { const el = await fixture(html``); expect(el.isConnected).to.be.true; });
it('23. removal', async () => { const el = await fixture(html``); el.remove(); expect(el.isConnected).to.be.false; });
it('24. outerHTML', async () => { const el = await fixture(html``); expect(el.outerHTML).to.contain('nile-date-picker'); });
it('25. matches', async () => { const el = await fixture(html``); expect(el.matches('.x')).to.be.true; });
it('26. closest', async () => { const el = await fixture(html``); expect(el.closest('nile-date-picker')).to.equal(el); });
it('27. cloneNode', async () => { const el = await fixture(html``); expect((el.cloneNode(true) as Element).tagName.toLowerCase()).to.equal('nile-date-picker'); });
it('28. 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('29. updateComplete', async () => { const el = await fixture(html``); const r = await el.updateComplete; expect(r).to.not.be.undefined; });
it('30. render method', async () => { const el = await fixture(html``); expect(el.render).to.be.a('function'); });
it('31. shadowRoot host', async () => { const el = await fixture(html``); expect(el.shadowRoot!.host).to.equal(el); });
it('32. class attr', async () => { const el = await fixture(html``); expect(el.classList.contains('dp')).to.be.true; });
it('33. id attr', async () => { const el = await fixture(html``); expect(el.id).to.equal('dp1'); });
it('34. hidden', async () => { const el = await fixture(html``); expect(el.hidden).to.be.true; });
it('35. nodeType', async () => { const el = await fixture(html``); expect(el.nodeType).to.equal(1); });
it('36. localName', async () => { const el = await fixture(html``); expect(el.localName).to.equal('nile-date-picker'); });
it('37. namespaceURI', async () => { const el = await fixture(html``); expect(el.namespaceURI).to.equal('http://www.w3.org/1999/xhtml'); });
it('38. ownerDocument', async () => { const el = await fixture(html``); expect(el.ownerDocument).to.equal(document); });
it('39. dynamic range', async () => { const el = await fixture(html``); el.range = true; await el.updateComplete; expect(el.range).to.be.true; });
it('40. dynamic type', async () => { const el = await fixture(html``); el.type = 'relative'; await el.updateComplete; expect(el.type).to.equal('relative'); });
it('41. multiple instances', async () => { const c = await fixture(html`
`); expect(c.querySelectorAll('nile-date-picker').length).to.equal(2); });
it('42. parent-child', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-date-picker')!.parentElement).to.equal(c); });
it('43. createElement', async () => { const el = document.createElement('nile-date-picker') as NileDatePicker; document.body.appendChild(el); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; document.body.removeChild(el); });
it('44. dataset', async () => { const el = await fixture(html``); expect(el.dataset.idx).to.equal('0'); });
it('45. classList add', async () => { const el = await fixture(html``); el.classList.add('z'); expect(el.classList.contains('z')).to.be.true; });
it('46. getBoundingClientRect', async () => { const el = await fixture(html``); expect(el.getBoundingClientRect()).to.exist; });
it('47. style attr', async () => { const el = await fixture(html``); expect(el.style.color).to.equal('red'); });
it('48. data attr', async () => { const el = await fixture(html``); expect(el.getAttribute('data-x')).to.equal('1'); });
it('49. aria-label', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-label')).to.equal('DP'); });
it('50. dir', async () => { const el = await fixture(html``); expect(el.dir).to.equal('rtl'); });
it('51. lang attr', async () => { const el = await fixture(html``); expect(el.lang).to.equal('en'); });
it('52. tabindex', async () => { const el = await fixture(html``); expect(el.getAttribute('tabindex')).to.equal('0'); });
it('53. requestUpdate', async () => { const el = await fixture(html``); el.requestUpdate(); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; });
it('54. shadow childNodes', async () => { const el = await fixture(html``); expect(el.shadowRoot!.childNodes.length).to.be.greaterThan(0); });
it('55. scrollIntoView', async () => { const el = await fixture(html``); expect(el.scrollIntoView).to.be.a('function'); });
it('56. focus method', async () => { const el = await fixture(html``); expect(el.focus).to.be.a('function'); });
it('57. blur method', async () => { const el = await fixture(html``); expect(el.blur).to.be.a('function'); });
it('58. class toggle', async () => { const el = await fixture(html``); el.classList.toggle('a'); expect(el.classList.contains('a')).to.be.true; });
it('59. toggle hidden', async () => { const el = await fixture(html``); el.hidden = true; expect(el.hidden).to.be.true; });
it('60. 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('61. nested in div', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-date-picker')).to.exist; });
it('62. no table', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('table')).to.be.null; });
it('63. no nav', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nav')).to.be.null; });
it('64. no aside', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('aside')).to.be.null; });
it('65. no textarea', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('textarea')).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. no canvas', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('canvas')).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. type reflects', async () => { const el = await fixture(html``); expect(el.getAttribute('type')).to.equal('relative'); });
it('75. dateFormat reflects', async () => { const el = await fixture(html``); expect(el.getAttribute('dateformat')).to.exist; });
it('76. no ul', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('ul')).to.be.null; });
it('77. no h1', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('h1')).to.be.null; });
it('78. no pre', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('pre')).to.be.null; });
it('79. no code', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('code')).to.be.null; });
it('80. title attr', async () => { const el = await fixture(html``); expect(el.title).to.equal('DP'); });
it('81. contains', async () => { const el = await fixture(html``); expect(el.contains(el)).to.be.true; });
it('82. no anchor', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('a')).to.be.null; });
it('83. no img', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('img')).to.be.null; });
it('84. dynamic dateFormat', async () => { const el = await fixture(html``); el.dateFormat = 'MM/DD/YYYY'; await el.updateComplete; expect(el.dateFormat).to.equal('MM/DD/YYYY'); });
it('85. dynamic open', async () => { const el = await fixture(html``); el.open = true; await el.updateComplete; expect(el.open).to.be.true; });
it('86. dynamic allowClear', async () => { const el = await fixture(html``); el.allowClear = true; await el.updateComplete; expect(el.allowClear).to.be.true; });
it('87. dynamic hideTypes', async () => { const el = await fixture(html``); el.hideTypes = true; await el.updateComplete; expect(el.hideTypes).to.be.true; });
it('88. dynamic hideTimeZone', async () => { const el = await fixture(html``); el.hideTimeZone = true; await el.updateComplete; expect(el.hideTimeZone).to.be.true; });
it('89. dynamic showManualInputs', async () => { const el = await fixture(html``); el.showManualInputs = true; await el.updateComplete; expect(el.showManualInputs).to.be.true; });
it('90. dynamic showYearDropdown', async () => { const el = await fixture(html``); el.showYearDropdown = true; await el.updateComplete; expect(el.showYearDropdown).to.be.true; });
it('91. dynamic showMonthDropdown', async () => { const el = await fixture(html``); el.showMonthDropdown = true; await el.updateComplete; expect(el.showMonthDropdown).to.be.true; });
it('92. dynamic syncDatePicker', async () => { const el = await fixture(html``); el.syncDatePicker = true; await el.updateComplete; expect(el.syncDatePicker).to.be.true; });
it('93. dynamic rangeSeparator', async () => { const el = await fixture(html``); el.rangeSeparator = ' to '; await el.updateComplete; expect(el.rangeSeparator).to.equal(' to '); });
it('94. hideDurationFields defaults empty', async () => { const el = await fixture(html``); expect(el.hideDurationFields).to.exist; });
it('95. allowedDates defaults', async () => { const el = await fixture(html``); expect(el.allowedDates).to.exist; });
it('96. no hr', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('hr')).to.be.null; });
it('97. no p tag', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('p')).to.be.null; });
it('98. role attr', async () => { const el = await fixture(html``); expect(el.getAttribute('role')).to.equal('dialog'); });
it('99. set doubleClickUnselect', async () => { const el = await fixture(html``); el.doubleClickUnselect = true; await el.updateComplete; expect(el.doubleClickUnselect).to.be.true; });
it('100. full integration', async () => { const el = await fixture(html``); expect(el.type).to.equal('absolute'); expect(el.range).to.be.true; expect(el.id).to.equal('dp1'); expect(el.dateFormat).to.equal('DD/MM/YYYY'); });
});