2021-03-21 13:21:22 +01:00
|
|
|
"use strict";
|
|
|
|
|
2024-10-09 00:25:41 +02:00
|
|
|
const assert = require("node:assert/strict");
|
2021-03-21 13:21:22 +01:00
|
|
|
|
2024-11-13 07:05:32 +01:00
|
|
|
const {run_test} = require("./lib/test.cjs");
|
2021-03-21 13:21:22 +01:00
|
|
|
|
2021-06-15 14:54:53 +02:00
|
|
|
/*
|
|
|
|
Note that the test runner automatically registers
|
|
|
|
all of our handlers.
|
|
|
|
*/
|
2021-03-21 13:21:22 +01:00
|
|
|
|
|
|
|
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");
|
|
|
|
});
|
2022-08-01 20:58:23 +02:00
|
|
|
|
2023-02-08 21:40:48 +01:00
|
|
|
run_test("tooltip_hotkey_hints", () => {
|
2022-08-01 20:58:23 +02:00
|
|
|
const args = {
|
|
|
|
hotkey_one: "Ctrl",
|
|
|
|
hotkey_two: "C",
|
|
|
|
};
|
|
|
|
|
2023-02-08 21:40:48 +01:00
|
|
|
const html = require("./templates/tooltip_hotkey_hints.hbs")(args);
|
|
|
|
const expected_html = `<span class="tooltip-hotkey-hints"><span class="tooltip-hotkey-hint">${args.hotkey_one}</span><span class="tooltip-hotkey-hint">${args.hotkey_two}</span></span>\n`;
|
2022-08-01 20:58:23 +02:00
|
|
|
assert.equal(html, expected_html);
|
|
|
|
});
|
2024-02-28 12:27:51 +01:00
|
|
|
|
|
|
|
run_test("popover_hotkey_hints", () => {
|
2024-03-20 23:17:45 +01:00
|
|
|
const args = {
|
|
|
|
hotkey_one: "Ctrl",
|
|
|
|
hotkey_two: "[",
|
|
|
|
};
|
|
|
|
|
|
|
|
const html = require("./templates/popover_hotkey_hints.hbs")(args);
|
|
|
|
const expected_html = `<span class="popover-menu-hotkey-hints"><span class="popover-menu-hotkey-hint">${args.hotkey_one}</span><span class="popover-menu-hotkey-hint">${args.hotkey_two}</span></span>\n`;
|
|
|
|
assert.equal(html, expected_html);
|
|
|
|
});
|
|
|
|
|
|
|
|
run_test("popover_hotkey_hints_shift_hotkey", () => {
|
2024-02-28 12:27:51 +01:00
|
|
|
const args = {
|
|
|
|
hotkey_one: "Shift",
|
|
|
|
hotkey_two: "V",
|
|
|
|
};
|
|
|
|
|
|
|
|
const html = require("./templates/popover_hotkey_hints.hbs")(args);
|
2024-03-20 23:17:45 +01:00
|
|
|
args.hotkey_one = "⇧"; // adjust_shift_hotkey
|
|
|
|
const expected_html = `<span class="popover-menu-hotkey-hints popover-contains-shift-hotkey" data-hotkey-hints="${args.hotkey_one},${args.hotkey_two}"><span class="popover-menu-hotkey-hint">${args.hotkey_one}</span><span class="popover-menu-hotkey-hint">${args.hotkey_two}</span></span>\n`;
|
2024-02-28 12:27:51 +01:00
|
|
|
assert.equal(html, expected_html);
|
|
|
|
});
|