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.

100 lines
1.9 KiB

const expect = require("chai").expect;
const Parse = require("../lib/index");
describe("Parser Checks", function () {
it("Bold Test", function () {
expect(Parse("**bold**")).to.eql([
{
type: "bold",
children: ["bold"],
},
]);
});
it("Strikethrough Test", function () {
expect(Parse("~~strikethrough~~")).to.eql([
{
type: "strikethrough",
children: ["strikethrough"],
},
]);
});
it("Italics Test", function () {
expect(Parse("_italics_")).to.eql([
{
type: "italics",
children: ["italics"],
},
]);
});
it("Underline Test", function () {
expect(Parse("==Underline==")).to.eql([
{
type: "underline",
children: ["Underline"],
},
]);
});
it("url Test", function () {
expect(Parse("[The Feathers](feathers.studio)")).to.eql([
{
type: "url",
children: ["The Feathers"],
url: "feathers.studio",
},
]);
});
it("Bold text inside the Bold text", function () {
expect(Parse("**Outer**InnerBold**Bold**")).to.eql([
{ type: "bold", children: ["Outer"] },
{ type: "text", children: ["InnerBold"] },
{ type: "bold", children: ["Bold"] },
]);
});
it("Bold text inside the Bold text", function () {
expect(Parse("**Outer**InnerBold**Bold**")).to.eql([
{ type: "bold", children: ["Outer"] },
{ type: "text", children: ["InnerBold"] },
{ type: "bold", children: ["Bold"] },
]);
});
it("Nested Check 1", function () {
expect(
Parse(
"**Bold_Italics~~strikethrough==underline==strikethrough~~Italics_Bold**",
),
).to.eql([
{
type: "bold",
children: [
"Bold",
{
type: "italics",
children: [
"Italics",
{
type: "strikethrough",
children: [
"strikethrough",
{ type: "underline", children: ["underline"] },
"strikethrough",
],
},
"Italics",
],
},
"Bold",
],
},
]);
});
it("");
});