From a5bc494d2ea27c1e2f9efaaabd29a8986c1330b5 Mon Sep 17 00:00:00 2001 From: Simon Weidacher <17548832+sweidac@users.noreply.github.com> Date: Thu, 5 Jan 2023 20:20:05 +0100 Subject: [PATCH] Adds tests for properties and indentation removal. --- peasy.test.js | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/peasy.test.js b/peasy.test.js index 45eb310..0d1119f 100644 --- a/peasy.test.js +++ b/peasy.test.js @@ -26,8 +26,6 @@ it('creates a deeper html structure', () => { `; - 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'); }); @@ -44,4 +42,56 @@ it('works with node interpolations', () => { 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'); + }); + }); \ No newline at end of file