mirror of
https://github.com/sweidac/peasy.git
synced 2025-07-27 19:31:55 +02:00
Adds tests for properties and indentation removal.
This commit is contained in:
@@ -26,8 +26,6 @@ it('creates a deeper html structure', () => {
|
|||||||
</div>
|
</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.querySelectorAll('span').length).toBe(2);
|
||||||
expect(view.querySelector('p').textContent).toBe('paragraph');
|
expect(view.querySelector('p').textContent).toBe('paragraph');
|
||||||
});
|
});
|
||||||
@@ -45,3 +43,55 @@ it('works with node interpolations', () => {
|
|||||||
expect(outerView).toBeInstanceOf(HTMLElement);
|
expect(outerView).toBeInstanceOf(HTMLElement);
|
||||||
expect(outerView.querySelector('.myuser').textContent).toBe('JohnDoe');
|
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');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Reference in New Issue
Block a user