2021-03-21 13:21:22 +01:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const {strict: assert} = require("assert");
|
|
|
|
|
2021-03-21 13:36:56 +01:00
|
|
|
const {JSDOM} = require("jsdom");
|
|
|
|
|
|
|
|
const {set_global, zrequire} = require("../zjsunit/namespace");
|
2021-03-21 13:21:22 +01:00
|
|
|
const {run_test} = require("../zjsunit/test");
|
|
|
|
|
2021-03-21 13:36:56 +01:00
|
|
|
set_global("DOMParser", new JSDOM().window.DOMParser);
|
2021-03-21 13:21:22 +01:00
|
|
|
zrequire("templates");
|
|
|
|
|
|
|
|
run_test("and", () => {
|
|
|
|
const args = {
|
|
|
|
last: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const html = require("./templates/and.hbs")(args);
|
|
|
|
assert.equal(html, "<p>empty and</p>\n<p>last and</p>\n\n");
|
|
|
|
});
|
2021-03-21 13:29:44 +01:00
|
|
|
|
|
|
|
run_test("or", () => {
|
|
|
|
const args = {
|
|
|
|
last: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const html = require("./templates/or.hbs")(args);
|
|
|
|
assert.equal(html, "\n<p>last or</p>\n<p>true or</p>\n");
|
|
|
|
});
|
2021-03-21 13:36:56 +01:00
|
|
|
|
|
|
|
run_test("rendered_markdown", () => {
|
|
|
|
const html = require("./templates/rendered_markdown.hbs")();
|
|
|
|
const expected_html =
|
|
|
|
'<a href="http://example.com" target="_blank" rel="noopener noreferrer" title="http://example.com/">good</a>\n';
|
|
|
|
assert.equal(html, expected_html);
|
|
|
|
});
|
2021-03-21 13:43:11 +01:00
|
|
|
|
|
|
|
run_test("numberFormat", () => {
|
|
|
|
const args = {
|
|
|
|
number: 1000000,
|
|
|
|
};
|
|
|
|
|
|
|
|
const html = require("./templates/numberFormat.hbs")(args);
|
|
|
|
assert.equal(html, "1,000,000\n");
|
|
|
|
});
|