Adds tests for properties and indentation removal.

This commit is contained in:
Simon Weidacher
2023-01-05 20:20:05 +01:00
parent 385530bccf
commit a5bc494d2e

View File

@@ -26,8 +26,6 @@ it('creates a deeper html structure', () => {
</div>
`;
expect(view.childElementCount).toBe(4);
expect(view.childNodes.length).toBe(4); // make sure we have no textnodes from the indentation
expect(view.querySelectorAll('span').length).toBe(2);
expect(view.querySelector('p').textContent).toBe('paragraph');
});
@@ -45,3 +43,55 @@ it('works with node interpolations', () => {
expect(outerView).toBeInstanceOf(HTMLElement);
expect(outerView.querySelector('.myuser').textContent).toBe('JohnDoe');
});
it('works with properties', () => {
const view = html`
<div class="foo" data-lol="sometext" aria-role="code">
<h1>Title</h1>
<span>Text</span>
<span>Text2</span>
<p>paragraph</p>
</div>
`;
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`
<div>
<h1>Title</h1>
<span>Text</span>
<span>Text2</span>
<p>paragraph</p>
</div>
`;
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`
<div class="foo"
data-lol="sometext"
aria-role="code">
<h1>Title</h1>
<span>Text</span>
<span>Text2</span>
<p>paragraph</p>
</div>
`;
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');
});
});