mirror of
https://github.com/Kornstalx/5etools-mirror-2.github.io.git
synced 2025-10-28 20:45:35 -05:00
v1.201.0
This commit is contained in:
67
test/jest/SplitByTags.test.js
Normal file
67
test/jest/SplitByTags.test.js
Normal file
@@ -0,0 +1,67 @@
|
||||
import "../../js/parser.js";
|
||||
import "../../js/utils.js";
|
||||
import "../../js/render.js";
|
||||
|
||||
describe("Splitting by tags", () => {
|
||||
it("Should handle a single tag", () => {
|
||||
expect(Renderer.splitByTags("aa {@b bb} cc"))
|
||||
.toStrictEqual([
|
||||
"aa ",
|
||||
"{@b bb}",
|
||||
" cc",
|
||||
]);
|
||||
|
||||
expect(Renderer.splitByTags("aa{@b bb}"))
|
||||
.toStrictEqual([
|
||||
"aa",
|
||||
"{@b bb}",
|
||||
]);
|
||||
|
||||
expect(Renderer.splitByTags("{@b bb}"))
|
||||
.toStrictEqual([
|
||||
"{@b bb}",
|
||||
]);
|
||||
|
||||
expect(Renderer.splitByTags("{@h}"))
|
||||
.toStrictEqual([
|
||||
"{@h}",
|
||||
]);
|
||||
});
|
||||
|
||||
it("Should handle multiple tags", () => {
|
||||
expect(Renderer.splitByTags("{@b {@i aaa} bb} {@b cc}"))
|
||||
.toStrictEqual([
|
||||
"{@b {@i aaa} bb}",
|
||||
" ",
|
||||
"{@b cc}",
|
||||
]);
|
||||
});
|
||||
|
||||
it("Should handle property injectors", () => {
|
||||
expect(Renderer.splitByTags("{=amount1/v} {=amount2}"))
|
||||
.toStrictEqual([
|
||||
"{=amount1/v}",
|
||||
" ",
|
||||
"{=amount2}",
|
||||
]);
|
||||
|
||||
expect(Renderer.splitByTags("{=amount1/v} {@unit {=amount1}|egg|eggs}"))
|
||||
.toStrictEqual([
|
||||
"{=amount1/v}",
|
||||
" ",
|
||||
"{@unit {=amount1}|egg|eggs}",
|
||||
]);
|
||||
});
|
||||
|
||||
it("Should handle non-tags", () => {
|
||||
expect(Renderer.splitByTags("{@@a {@@b"))
|
||||
.toStrictEqual([
|
||||
"{@@a {@@b",
|
||||
]);
|
||||
|
||||
expect(Renderer.splitByTags("{@}"))
|
||||
.toStrictEqual([
|
||||
"{@}",
|
||||
]);
|
||||
});
|
||||
});
|
||||
31
test/jest/StripTags.test.js
Normal file
31
test/jest/StripTags.test.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import "../../js/parser.js";
|
||||
import "../../js/utils.js";
|
||||
import "../../js/render.js";
|
||||
|
||||
describe("Stripping tags", () => {
|
||||
it("Should handle a single tag", () => {
|
||||
expect(Renderer.stripTags("aa {@b bb} cc")).toBe("aa bb cc");
|
||||
expect(Renderer.stripTags("aa{@b bb}")).toBe("aabb");
|
||||
expect(Renderer.stripTags("{@b bb}")).toBe("bb");
|
||||
expect(Renderer.stripTags("{@h}")).toBe("Hit: ");
|
||||
});
|
||||
|
||||
it("Should handle multiple tags", () => {
|
||||
expect(Renderer.stripTags("{@b {@i aaa} bb} {@b cc}")).toBe("aaa bb cc");
|
||||
});
|
||||
|
||||
it("Should ignore property injectors", () => {
|
||||
expect(Renderer.stripTags("{=amount1/v} {=amount2}")).toBe("{=amount1/v} {=amount2}");
|
||||
expect(Renderer.stripTags("{=amount1/v} {@unit {=amount1}|egg|eggs}")).toBe("{=amount1/v} egg");
|
||||
});
|
||||
|
||||
it("Should ignore tags in allowlist", () => {
|
||||
expect(Renderer.stripTags("{@b {@i aaa} bb} {@b cc}", {allowlistTags: new Set(["@i"])})).toBe("{@i aaa} bb cc");
|
||||
expect(Renderer.stripTags("{@b {@i aaa} bb} {@b cc}", {allowlistTags: new Set([])})).toBe("aaa bb cc");
|
||||
});
|
||||
|
||||
it("Should only remove tags in blocklist", () => {
|
||||
expect(Renderer.stripTags("{@b {@i aaa} bb} {@b cc}", {blocklistTags: new Set(["@b"])})).toBe("{@i aaa} bb cc");
|
||||
expect(Renderer.stripTags("{@b {@i aaa} bb} {@b cc}", {blocklistTags: new Set([])})).toBe("{@b {@i aaa} bb} {@b cc}");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user