import { expect, fixture, html } from '@open-wc/testing'; import './nile-stepper-item'; import type { NileStepperItem } from './nile-stepper-item'; describe('NileStepperItem', () => { 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-stepper-item'); }); it('4. title defaults empty', async () => { const el = await fixture(html``); expect(el.title).to.equal(''); }); it('5. subtitle defaults empty', async () => { const el = await fixture(html``); expect(el.subtitle).to.equal(''); }); it('6. completed defaults false', async () => { const el = await fixture(html``); expect(el.completed).to.be.false; }); it('7. current defaults false', async () => { const el = await fixture(html``); expect(el.current).to.be.false; }); it('8. set title', async () => { const el = await fixture(html``); expect(el.title).to.equal('Step 1'); }); it('9. set subtitle', async () => { const el = await fixture(html``); expect(el.subtitle).to.equal('Description'); }); it('10. set completed', async () => { const el = await fixture(html``); expect(el.hasAttribute('completed')).to.be.true; }); it('11. set current', async () => { const el = await fixture(html``); expect(el.hasAttribute('current')).to.be.true; }); it('12. stepper__item class', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('.stepper__item')).to.exist; }); it('13. stepper__line__content class', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('.stepper__line__content')).to.exist; }); it('14. stepper__line__container class', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('.stepper__line__container')).to.exist; }); it('15. stepper__item__bulletin class', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('.stepper__item__bulletin')).to.exist; }); it('16. stepper__item__bulletin class', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('.stepper__item__bulletin')).to.exist; }); it('17. part item', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="item"]')).to.exist; }); it('18. part line-content', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="line-content"]')).to.exist; }); it('19. part bulletin', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="bulletin"]')).to.exist; }); it('20. title reflects', async () => { const el = await fixture(html``); expect(el.hasAttribute('title')).to.be.true; }); it('21. subtitle reflects', async () => { const el = await fixture(html``); expect(el.hasAttribute('subtitle')).to.be.true; }); it('22. completed reflects', async () => { const el = await fixture(html``); expect(el.hasAttribute('completed')).to.be.true; }); it('23. current reflects', async () => { const el = await fixture(html``); expect(el.hasAttribute('current')).to.be.true; }); it('24. getSvg method', async () => { const el = await fixture(html``); expect(el.getSvg).to.be.a('function'); }); it('25. has styles', async () => { expect((await import('./nile-stepper-item')).NileStepperItem.styles).to.exist; }); it('26. is defined', async () => { expect(customElements.get('nile-stepper-item')).to.exist; }); it('27. shadow mode', async () => { const el = await fixture(html``); expect(el.shadowRoot!.mode).to.equal('open'); }); it('28. isConnected', async () => { const el = await fixture(html``); expect(el.isConnected).to.be.true; }); it('29. removal', async () => { const el = await fixture(html``); el.remove(); expect(el.isConnected).to.be.false; }); it('30. outerHTML', async () => { const el = await fixture(html``); expect(el.outerHTML).to.contain('nile-stepper-item'); }); it('31. matches', async () => { const el = await fixture(html``); expect(el.matches('.x')).to.be.true; }); it('32. closest', async () => { const el = await fixture(html``); expect(el.closest('nile-stepper-item')).to.equal(el); }); it('33. cloneNode', async () => { const el = await fixture(html``); expect((el.cloneNode(true) as Element).tagName.toLowerCase()).to.equal('nile-stepper-item'); }); it('34. 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('35. updateComplete', async () => { const el = await fixture(html``); const r = await el.updateComplete; expect(r).to.not.be.undefined; }); it('36. render method', async () => { const el = await fixture(html``); expect(el.render).to.be.a('function'); }); it('37. shadowRoot host', async () => { const el = await fixture(html``); expect(el.shadowRoot!.host).to.equal(el); }); it('38. class attr', async () => { const el = await fixture(html``); expect(el.classList.contains('si')).to.be.true; }); it('39. id attr', async () => { const el = await fixture(html``); expect(el.id).to.equal('si1'); }); it('40. hidden', async () => { const el = await fixture(html``); expect(el.hidden).to.be.true; }); it('41. nodeType', async () => { const el = await fixture(html``); expect(el.nodeType).to.equal(1); }); it('42. localName', async () => { const el = await fixture(html``); expect(el.localName).to.equal('nile-stepper-item'); }); it('43. namespaceURI', async () => { const el = await fixture(html``); expect(el.namespaceURI).to.equal('http://www.w3.org/1999/xhtml'); }); it('44. ownerDocument', async () => { const el = await fixture(html``); expect(el.ownerDocument).to.equal(document); }); it('45. dynamic title', async () => { const el = await fixture(html``); el.title = 'New'; await el.updateComplete; expect(el.title).to.equal('New'); }); it('46. dynamic subtitle', async () => { const el = await fixture(html``); el.subtitle = 'Desc'; await el.updateComplete; expect(el.subtitle).to.equal('Desc'); }); it('47. dynamic completed', async () => { const el = await fixture(html``); el.completed = true; await el.updateComplete; expect(el.completed).to.be.true; }); it('48. dynamic current', async () => { const el = await fixture(html``); el.current = true; await el.updateComplete; expect(el.current).to.be.true; }); it('49. multiple instances', async () => { const c = await fixture(html`
`); expect(c.querySelectorAll('nile-stepper-item').length).to.equal(2); }); it('50. parent-child', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-stepper-item')!.parentElement).to.equal(c); }); it('51. createElement', async () => { const el = document.createElement('nile-stepper-item') as NileStepperItem; document.body.appendChild(el); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; document.body.removeChild(el); }); it('52. dataset', async () => { const el = await fixture(html``); expect(el.dataset.idx).to.equal('0'); }); it('53. classList add', async () => { const el = await fixture(html``); el.classList.add('z'); expect(el.classList.contains('z')).to.be.true; }); it('54. getBoundingClientRect', async () => { const el = await fixture(html``); expect(el.getBoundingClientRect()).to.exist; }); it('55. no form', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('form')).to.be.null; }); it('56. no input', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('input')).to.be.null; }); it('57. no button', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('button')).to.be.null; }); it('58. no anchor', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('a')).to.be.null; }); it('59. no img', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('img')).to.be.null; }); it('60. no slot', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('slot')).to.be.null; }); it('61. style attr', async () => { const el = await fixture(html``); expect(el.style.color).to.equal('red'); }); it('62. data attr', async () => { const el = await fixture(html``); expect(el.getAttribute('data-x')).to.equal('1'); }); it('63. aria-label', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-label')).to.equal('Step'); }); it('64. role', async () => { const el = await fixture(html``); expect(el.getAttribute('role')).to.equal('listitem'); }); it('65. dir', async () => { const el = await fixture(html``); expect(el.dir).to.equal('rtl'); }); it('66. lang attr', async () => { const el = await fixture(html``); expect(el.lang).to.equal('en'); }); it('67. tabindex', async () => { const el = await fixture(html``); expect(el.getAttribute('tabindex')).to.equal('0'); }); it('68. requestUpdate', async () => { const el = await fixture(html``); el.requestUpdate(); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; }); it('69. shadow childNodes', async () => { const el = await fixture(html``); expect(el.shadowRoot!.childNodes.length).to.be.greaterThan(0); }); it('70. scrollIntoView', async () => { const el = await fixture(html``); expect(el.scrollIntoView).to.be.a('function'); }); it('71. focus method', async () => { const el = await fixture(html``); expect(el.focus).to.be.a('function'); }); it('72. blur method', async () => { const el = await fixture(html``); expect(el.blur).to.be.a('function'); }); it('73. class toggle', async () => { const el = await fixture(html``); el.classList.toggle('a'); expect(el.classList.contains('a')).to.be.true; }); it('74. toggle hidden', async () => { const el = await fixture(html``); el.hidden = true; expect(el.hidden).to.be.true; }); it('75. 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('76. nested in div', async () => { const c = await fixture(html`
`); expect(c.querySelector('nile-stepper-item')).to.exist; }); it('77. no table', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('table')).to.be.null; }); it('78. no ul', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('ul')).to.be.null; }); it('79. no canvas', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('canvas')).to.be.null; }); it('80. no video', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('video')).to.be.null; }); it('81. no audio', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('audio')).to.be.null; }); it('82. no nav', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nav')).to.be.null; }); it('83. no aside', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('aside')).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. aria-describedby', async () => { const el = await fixture(html``); expect(el.getAttribute('aria-describedby')).to.equal('d'); }); it('90. 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('91. no nile-icon', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nile-icon')).to.be.null; }); it('92. no nile-badge', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nile-badge')).to.be.null; }); it('93. no nile-button', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nile-button')).to.be.null; }); it('94. no nile-divider', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('nile-divider')).to.be.null; }); it('95. part line-container', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="line-container"]')).to.exist; }); it('96. part bulletin', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('[part="bulletin"]')).to.exist; }); it('97. div elements', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelectorAll('div').length).to.be.greaterThan(0); }); it('98. no h1', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('h1')).to.be.null; }); it('99. no p', async () => { const el = await fixture(html``); expect(el.shadowRoot!.querySelector('p')).to.be.null; }); it('100. full integration', async () => { const el = await fixture(html``); expect(el.title).to.equal('Step 1'); expect(el.subtitle).to.equal('First step'); expect(el.id).to.equal('si1'); expect(el.shadowRoot!.querySelector('.stepper__item')).to.exist; expect(el.shadowRoot!.querySelector('.stepper__item__bulletin')).to.exist; }); });