import html from './index.mjs'; it('it exports the tagging function', () => { expect(html).toBeInstanceOf(Function); }); it('creates simple html elements', () => { const div = html`
`; expect(div).toBeInstanceOf(HTMLElement); expect(div.nodeName).toBe('DIV'); const span = html``; expect(span).toBeInstanceOf(HTMLElement); expect(span.nodeName).toBe('SPAN'); }); it('creates a deeper html structure', () => { const view = html`

Title

Text Text2

paragraph

`; expect(view.querySelectorAll('span').length).toBe(2); expect(view.querySelector('p').textContent).toBe('paragraph'); }); it('works with interpolations', () => { const divWithText = html`
${'Text'}
`; expect(divWithText.textContent).toBe('Text'); }); it('works with node interpolations', () => { const innerView = html`
JohnDoe
`, outerView = html`
${innerView}
`; expect(outerView).toBeInstanceOf(HTMLElement); expect(outerView.querySelector('.myuser').textContent).toBe('JohnDoe'); }); it('works with properties', () => { const view = html`

Title

Text Text2

paragraph

`; expect(view.childElementCount).toBe(4); expect(view.childNodes.length).toBe(4); // make sure we have no textnodes from the indentation expect(view.getAttribute('data-lol')).toBe('sometext'); expect(view.getAttribute('aria-role')).toBe('code'); }); describe('tab-indenations removal', () => { it('removes basic tab-indentation', () => { const view = html`

Title

Text Text2

paragraph

`; expect(view.childElementCount).toBe(4); expect(view.childNodes.length).toBe(4); // make sure we have no textnodes from the indentation }); it('removes tab-indentations when used with properties', () => { const view = html`

Title

Text Text2

paragraph

`; expect(view.childElementCount).toBe(4); expect(view.childNodes.length).toBe(4); // make sure we have no textnodes from the indentation expect(view.getAttribute('data-lol')).toBe('sometext'); expect(view.getAttribute('aria-role')).toBe('code'); }); });