template.test.js 880 B

12345678910111213141516
  1. const templateMinify = require("../minifyTemplate.js")
  2. test('Test html string with template', () => {
  3. expect(templateMinify("let echo = 1;\r html`\r\r\n <div> html test ${echo}\r</div> `",{collapseWhitespace: true}))
  4. .toBe("let echo=1;html`<div>html test ${echo}</div>`;");
  5. });
  6. test('Test html string with nested template', () => {
  7. expect(templateMinify("let echo = 1;\r html`\r\r\n <div> html test ${echo ? html`<div>\r\nEcho\r\n</div>`:``}\r</div> `",{collapseWhitespace: true}))
  8. .toBe("let echo=1;html`<div>html test ${echo?html`<div>Echo</div>`:``}</div>`;");
  9. });
  10. test('Test html string with template in attribute', () => {
  11. expect(templateMinify("let echo = 1;\r html`\r\r\n <div ${echo}> html test \r</div> `",{collapseWhitespace: true}))
  12. .toBe("let echo=1;html`<div ${echo}>html test</div>`;");
  13. });