Browse Source

changes in compileText for links representation

develop
arunkumar 4 years ago
parent
commit
96150d005a
  1. 2
      lib/compileText.js
  2. 4
      test/compileText.test.js

2
lib/compileText.js

@ -8,7 +8,7 @@ function CompileText(ast) {
let result = ""; let result = "";
if (element.type === "url") { if (element.type === "url") {
result = mapper(element.children); result = mapper(element.children);
str += mapper(element.children) + " " + element.url; str += mapper(element.children) + " (" + element.url + ")";
} else { } else {
result = mapper(element.children); result = mapper(element.children);
str = str + result; str = str + result;

4
test/compileText.test.js

@ -16,7 +16,7 @@ describe("Compile AST to Raw String", function () {
const ast = [ const ast = [
{ type: "url", children: ["The Feathers"], url: "feathers.studio" }, { type: "url", children: ["The Feathers"], url: "feathers.studio" },
]; ];
expect(CompileText(ast)).to.eql("The Feathers feathers.studio"); expect(CompileText(ast)).to.eql("The Feathers (feathers.studio)");
}); });
it("Formatted Link AST", function () { it("Formatted Link AST", function () {
@ -32,7 +32,7 @@ describe("Compile AST to Raw String", function () {
url: "feathers.studio", url: "feathers.studio",
}, },
]; ];
expect(CompileText(ast)).to.eql("The Feathers feathers.studio"); expect(CompileText(ast)).to.eql("The Feathers (feathers.studio)");
}); });
// it("Wrongly Formatted Link AST", function () { // it("Wrongly Formatted Link AST", function () {

Loading…
Cancel
Save