|
|
|
const expect = require("chai").expect;
|
|
|
|
const CompileText = require("../lib/compileText");
|
|
|
|
|
|
|
|
describe("Compile AST to Raw String", function () {
|
|
|
|
it("Simple AST", function () {
|
|
|
|
const ast = [
|
|
|
|
{
|
|
|
|
type: "underline",
|
|
|
|
children: ["The", { type: "bold", children: ["KING"] }, "Maker"],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
expect(CompileText(ast)).to.eql("TheKINGMaker");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Link AST", function () {
|
|
|
|
const ast = [
|
|
|
|
{ type: "url", children: ["The Feathers"], url: "feathers.studio" },
|
|
|
|
];
|
|
|
|
expect(CompileText(ast)).to.eql("The Feathers (feathers.studio)");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Formatted Link AST", function () {
|
|
|
|
const ast = [
|
|
|
|
{
|
|
|
|
type: "url",
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
type: "bold",
|
|
|
|
children: ["The ", { type: "underline", children: ["Feathers"] }],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
url: "feathers.studio",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
expect(CompileText(ast)).to.eql("The Feathers (feathers.studio)");
|
|
|
|
});
|
|
|
|
|
|
|
|
// it("Wrongly Formatted Link AST", function () {
|
|
|
|
// const ast = [
|
|
|
|
// { type: "bold", children: ["[The ==Feathers==](feathers.studio)"] },
|
|
|
|
// ];
|
|
|
|
// expect(CompileText(ast)).to.eql("[The ==Feathers==](feathers.studio)");
|
|
|
|
// });
|
|
|
|
|
|
|
|
it("Nested AST", function () {
|
|
|
|
const ast = [
|
|
|
|
{
|
|
|
|
type: "bold",
|
|
|
|
children: [
|
|
|
|
"Bold",
|
|
|
|
{
|
|
|
|
type: "italics",
|
|
|
|
children: [
|
|
|
|
"Italics",
|
|
|
|
{
|
|
|
|
type: "strikethrough",
|
|
|
|
children: [
|
|
|
|
"strikethrough",
|
|
|
|
{ type: "underline", children: ["underline"] },
|
|
|
|
"strikethrough",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
"Italics",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
"Bold",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
expect(CompileText(ast)).to.equal(
|
|
|
|
"BoldItalicsstrikethroughunderlinestrikethroughItalicsBold",
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|