import './process-polyfill'; import { expect, fixture, html } from '@open-wc/testing'; import './nile-lite-tooltip'; import type { NileliteTooltip } from './nile-lite-tooltip'; describe('NileliteTooltip', () => { it('1. renders', async () => { const el = await fixture(html``); expect(el).to.exist; }); it('2. renders to light DOM', async () => { const el = await fixture(html``); expect(el.renderRoot).to.equal(el); }); it('3. tag name', async () => { const el = await fixture(html``); expect(el.tagName.toLowerCase()).to.equal('nile-lite-tooltip'); }); it('4. is defined', async () => { expect(customElements.get('nile-lite-tooltip')).to.exist; }); it('5. has styles', async () => { expect((await import('./nile-lite-tooltip')).NileliteTooltip.styles).to.exist; }); it('6. light DOM mode', async () => { const el = await fixture(html``); expect(el.shadowRoot).to.be.null; }); it('7. isConnected', async () => { const el = await fixture(html``); expect(el.isConnected).to.be.true; }); it('8. removal', async () => { const el = await fixture(html``); el.remove(); expect(el.isConnected).to.be.false; }); it('9. outerHTML', async () => { const el = await fixture(html``); expect(el.outerHTML).to.contain('nile-lite-tooltip'); }); it('10. matches', async () => { const el = await fixture(html``); expect(el.matches('.x')).to.be.true; }); it('11. closest', async () => { const el = await fixture(html``); expect(el.closest('nile-lite-tooltip')).to.equal(el); }); it('12. cloneNode', async () => { const el = await fixture(html``); expect((el.cloneNode(true) as Element).tagName.toLowerCase()).to.equal('nile-lite-tooltip'); }); it('13. 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('14. updateComplete', async () => { const el = await fixture(html``); const r = await el.updateComplete; expect(r).to.not.be.undefined; }); // it('15. render method', async () => { const el = await fixture(html``); expect(el.render).to.be.a('function'); }); it('16. renderRoot is self', async () => { const el = await fixture(html``); expect(el.renderRoot).to.equal(el); }); it('17. class attr', async () => { const el = await fixture(html``); expect(el.classList.contains('tt')).to.be.true; }); it('18. id attr', async () => { const el = await fixture(html``); expect(el.id).to.equal('tt1'); }); it('19. hidden', async () => { const el = await fixture(html``); expect(el.hidden).to.be.true; }); it('20. nodeType', async () => { const el = await fixture(html``); expect(el.nodeType).to.equal(1); }); it('21. localName', async () => { const el = await fixture(html``); expect(el.localName).to.equal('nile-lite-tooltip'); }); it('22. namespaceURI', async () => { const el = await fixture(html``); expect(el.namespaceURI).to.equal('http://www.w3.org/1999/xhtml'); }); it('23. ownerDocument', async () => { const el = await fixture(html``); expect(el.ownerDocument).to.equal(document); }); it('24. multiple instances', async () => { const c = await fixture(html`
`); expect(c.querySelectorAll('nile-lite-tooltip').length).to.equal(2); }); it('25. parent-child', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-lite-tooltip')!.parentElement).to.equal(c); }); it('26. createElement', async () => { const el = document.createElement('nile-lite-tooltip') as NileliteTooltip; document.body.appendChild(el); await el.updateComplete; expect(el.isConnected).to.be.true; document.body.removeChild(el); }); it('27. dataset', async () => { const el = await fixture(html``); expect(el.dataset.idx).to.equal('0'); }); it('28. classList add', async () => { const el = await fixture(html``); el.classList.add('z'); expect(el.classList.contains('z')).to.be.true; }); it('29. getBoundingClientRect', async () => { const el = await fixture(html``); expect(el.getBoundingClientRect()).to.exist; }); it('30. style attr', async () => { const el = await fixture(html``); expect(el.style.color).to.equal('red'); }); it('31. aria-label', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-label')).to.equal('TT'); }); it('32. dir', async () => { const el = await fixture(html``); expect(el.dir).to.equal('rtl'); }); it('33. lang attr', async () => { const el = await fixture(html``); expect(el.lang).to.equal('en'); }); it('34. tabindex', async () => { const el = await fixture(html``); expect(el.getAttribute('tabindex')).to.equal('0'); }); it('35. requestUpdate', async () => { const el = await fixture(html``); el.requestUpdate(); await el.updateComplete; expect(el.isConnected).to.be.true; }); it('36. childNodes', async () => { const el = await fixture(html``); expect(el.childNodes.length).to.be.greaterThanOrEqual(0); }); it('37. scrollIntoView', async () => { const el = await fixture(html``); expect(el.scrollIntoView).to.be.a('function'); }); it('38. focus method', async () => { const el = await fixture(html``); expect(el.focus).to.be.a('function'); }); it('39. blur method', async () => { const el = await fixture(html``); expect(el.blur).to.be.a('function'); }); it('40. class toggle', async () => { const el = await fixture(html``); el.classList.toggle('a'); expect(el.classList.contains('a')).to.be.true; }); it('41. toggle hidden', async () => { const el = await fixture(html``); el.hidden = true; expect(el.hidden).to.be.true; }); it('42. 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('43. nested in div', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-lite-tooltip')).to.exist; }); it('44. default content', async () => { const el = await fixture(html``); expect(el.content).to.equal(''); }); it('45. set content', async () => { const el = await fixture(html``); expect(el.content).to.equal('Tip'); }); it('46. default placement', async () => { const el = await fixture(html``); expect(el.placement).to.exist; }); it('47. set placement', async () => { const el = await fixture(html``); expect(el.placement).to.equal('bottom'); }); it('48. no canvas', async () => { const el = await fixture(html``); expect(el.querySelector('canvas')).to.be.null; }); it('49. no video', async () => { const el = await fixture(html``); expect(el.querySelector('video')).to.be.null; }); it('50. no audio', async () => { const el = await fixture(html``); expect(el.querySelector('audio')).to.be.null; }); it('51. no nav', async () => { const el = await fixture(html``); expect(el.querySelector('nav')).to.be.null; }); it('52. no aside', async () => { const el = await fixture(html``); expect(el.querySelector('aside')).to.be.null; }); it('53. no table', async () => { const el = await fixture(html``); expect(el.querySelector('table')).to.be.null; }); it('54. no img', async () => { const el = await fixture(html``); expect(el.querySelector('img')).to.be.null; }); it('55. no anchor', async () => { const el = await fixture(html``); expect(el.querySelector('a')).to.be.null; }); it('56. no svg', async () => { const el = await fixture(html``); expect(el.querySelector('svg')).to.be.null; }); it('57. no form', async () => { const el = await fixture(html``); expect(el.querySelector('form')).to.be.null; }); it('58. title attr', async () => { const el = await fixture(html``); expect(el.title).to.equal('TT'); }); it('59. no h1', async () => { const el = await fixture(html``); expect(el.querySelector('h1')).to.be.null; }); it('60. no pre', async () => { const el = await fixture(html``); expect(el.querySelector('pre')).to.be.null; }); it('61. no code', async () => { const el = await fixture(html``); expect(el.querySelector('code')).to.be.null; }); it('62. no hr', async () => { const el = await fixture(html``); expect(el.querySelector('hr')).to.be.null; }); it('63. no p', async () => { const el = await fixture(html``); expect(el.querySelector('p')).to.be.null; }); it('64. no ul', async () => { const el = await fixture(html``); expect(el.querySelector('ul')).to.be.null; }); it('65. no textarea', async () => { const el = await fixture(html``); expect(el.querySelector('textarea')).to.be.null; }); it('66. no select', async () => { const el = await fixture(html``); expect(el.querySelector('select')).to.be.null; }); it('67. no nile-badge', async () => { const el = await fixture(html``); expect(el.querySelector('nile-badge')).to.be.null; }); it('68. no nile-radio', async () => { const el = await fixture(html``); expect(el.querySelector('nile-radio')).to.be.null; }); it('69. no nile-dialog', async () => { const el = await fixture(html``); expect(el.querySelector('nile-dialog')).to.be.null; }); it('70. no nile-drawer', async () => { const el = await fixture(html``); expect(el.querySelector('nile-drawer')).to.be.null; }); it('71. no nile-slider', async () => { const el = await fixture(html``); expect(el.querySelector('nile-slider')).to.be.null; }); it('72. no nile-accordion', async () => { const el = await fixture(html``); expect(el.querySelector('nile-accordion')).to.be.null; }); it('73. setAttribute data', async () => { const el = await fixture(html``); el.setAttribute('data-test', '1'); expect(el.dataset.test).to.equal('1'); }); it('74. removeAttribute hidden', async () => { const el = await fixture(html``); el.removeAttribute('hidden'); expect(el.hidden).to.be.false; }); it('75. setAttribute class', async () => { const el = await fixture(html``); el.setAttribute('class', 'test'); expect(el.classList.contains('test')).to.be.true; }); it('76. aria-describedby', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-describedby')).to.equal('d'); }); it('77. multiple re-renders', async () => { const el = await fixture(html``); for (let i = 0; i < 3; i++) { el.requestUpdate(); await el.updateComplete; } expect(el.isConnected).to.be.true; }); it('78. contains', async () => { const el = await fixture(html`C`); expect(el.contains(el.querySelector('#s1'))).to.be.true; }); it('79. data attr', async () => { const el = await fixture(html``); expect(el.getAttribute('data-x')).to.equal('1'); }); it('80. role attr', async () => { const el = await fixture(html``); expect(el.getAttribute('role')).to.equal('tooltip'); }); it('81. no section', async () => { const el = await fixture(html``); expect(el.querySelector('section')).to.be.null; }); it('82. no header', async () => { const el = await fixture(html``); expect(el.querySelector('header')).to.be.null; }); it('83. no footer', async () => { const el = await fixture(html``); expect(el.querySelector('footer')).to.be.null; }); it('84. no main', async () => { const el = await fixture(html``); expect(el.querySelector('main')).to.be.null; }); it('85. no article', async () => { const el = await fixture(html``); expect(el.querySelector('article')).to.be.null; }); it('86. no nile-toolbar', async () => { const el = await fixture(html``); expect(el.querySelector('nile-toolbar')).to.be.null; }); it('87. no nile-link', async () => { const el = await fixture(html``); expect(el.querySelector('nile-link')).to.be.null; }); it('88. no nile-menu', async () => { const el = await fixture(html``); expect(el.querySelector('nile-menu')).to.be.null; }); it('89. no nile-textarea', async () => { const el = await fixture(html``); expect(el.querySelector('nile-textarea')).to.be.null; }); it('90. no nile-card', async () => { const el = await fixture(html``); expect(el.querySelector('nile-card')).to.be.null; }); it('91. no nile-tab', async () => { const el = await fixture(html``); expect(el.querySelector('nile-tab')).to.be.null; }); it('92. no nile-stepper', async () => { const el = await fixture(html``); expect(el.querySelector('nile-stepper')).to.be.null; }); it('93. no nile-pagination', async () => { const el = await fixture(html``); expect(el.querySelector('nile-pagination')).to.be.null; }); it('94. no nile-calendar', async () => { const el = await fixture(html``); expect(el.querySelector('nile-calendar')).to.be.null; }); it('95. no nile-select', async () => { const el = await fixture(html``); expect(el.querySelector('nile-select')).to.be.null; }); it('96. no nile-input', async () => { const el = await fixture(html``); expect(el.querySelector('nile-input')).to.be.null; }); it('97. no nile-checkbox', async () => { const el = await fixture(html``); expect(el.querySelector('nile-checkbox')).to.be.null; }); it('98. default slot', async () => { const el = await fixture(html``); expect(el.querySelector('slot') || el.renderRoot === el).to.be.ok; }); it('99. no nile-button', async () => { const el = await fixture(html``); expect(el.querySelector('nile-button')).to.be.null; }); it('100. full integration', async () => { const el = await fixture(html``); expect(el.content).to.equal('Info'); expect(el.placement).to.equal('top'); expect(el.id).to.equal('tt1'); expect(el.renderRoot).to.equal(el); }); });