const expect = require("chai").expect; const CompileHTML = require("../lib/compileHTML"); describe("Compile AST to HTML String", function () { it("Simple AST", function () { const ast = [ { type: "bold", children: ["my"] }, { type: "text", children: ["simple"] }, { type: "italics", children: ["AST"] }, ]; const expectedOutput = '

mysimpleAST

'; expect(CompileHTML(ast)).to.eql(expectedOutput); }); 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", ], }, ]; const expectedOutput = '

BoldItalicsstrikethroughunderlinestrikethroughItalicsBold

'; expect(CompileHTML(ast)).to.eql(expectedOutput); }); it("Link AST", function () { const ast = [ { type: "url", children: ["The Feathers"], url: "feathers.studio" }, ]; const expectedOutput = '

The Feathers

'; expect(CompileHTML(ast)).to.eql(expectedOutput); }); it("Formatted Link AST - 1", function () { const ast = [ { type: "url", children: [{ type: "bold", children: ["The Feathers"] }], url: "feathers.studio", }, ]; const expectedOutput = '

The Feathers

'; expect(CompileHTML(ast)).to.eql(expectedOutput); }); it("Formatted Link AST - 2", function () { const ast = [ { type: "url", children: [ { type: "bold", children: ["The ", { type: "underline", children: ["Feathers"] }], }, ], url: "feathers.studio", }, ]; const expectedOutput = '

The Feathers

'; expect(CompileHTML(ast)).to.eql(expectedOutput); }); });