sokko-g/tests/toolbox-modules.test.mjs
Shinuwa 2e6d8a2c0c
All checks were successful
Deploy Sokko G / deploy (push) Successful in 7s
keepsafe rework & alert ajustments
2026-07-26 17:48:14 +02:00

28 lines
1.3 KiB
JavaScript

// Rôle : teste les parseurs d'import texte utilisés par les outils toolbox.
import { test } from "node:test";
import assert from "node:assert/strict";
import { parseColonImportLines } from "../website/src/features/toolboxes/modules/textImport.js";
import { getTimePatternRecurrenceMs, getTimePatternTargetMs } from "../website/src/features/toolboxes/modules/timerUtils.js";
test("colon text import keeps urls intact after the first separator", () => {
assert.deepEqual(parseColonImportLines("Build:https://example.com/build?class=rogue\nPotion:10"), [
{ label: "Build", value: "https://example.com/build?class=rogue" },
{ label: "Potion", value: "10" }
]);
});
test("colon text import accepts labels without value", () => {
assert.deepEqual(parseColonImportLines("Simple item"), [
{ label: "Simple item", value: "" }
]);
});
test("time pattern recurrence uses configured frequency instead of next remaining delay", () => {
const now = new Date(2026, 0, 1, 13, 23, 45, 0).getTime();
const target = getTimePatternTargetMs("X:24:X", now);
assert.equal(new Date(target).getHours(), 13);
assert.equal(new Date(target).getMinutes(), 24);
assert.equal(new Date(target).getSeconds(), 0);
assert.equal(getTimePatternRecurrenceMs("X:24:X"), 60 * 60 * 1000);
assert.equal(getTimePatternRecurrenceMs("X:X:30"), 60 * 1000);
});