You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

74 lines
1.6 KiB

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",
);
});
});