deno_sample_test.tsimport { parse } from "https://esm.sh/@progfay/scrapbox-parser@7.2.0";
import { assertEquals } from "https://deno.land/std@0.121.0/testing/asserts.ts";
Deno.test("parse()のテスト", () => {
const text = [
"scrapbox-parser",
"[Scrapbox記法]の[parser] by [/progfay-pub/progfay.icon]",
" [/icons/github.icon][https://github.com/progfay/scrapbox-parser progfay/scrapbox-parser]",
" かなり高頻度にメンテナンスされている",
"",
"Scrapbox内部で使っているparserとは若干違う",
].join("\n");
const expect = [
{ type: "title", text: "scrapbox-parser"},
{
indent: 0,
type: "line",
nodes: [
{
type: "link",
raw: "[Scrapbox記法]",
pathType: "relative",
href: "Scrapbox記法",
content: ""
},
{ type: "plain", raw: "の", text: "の" },
{ type: "link", raw: "[parser]", pathType: "relative", href: "parser", content: "" },
{ type: "plain", raw: " by ", text: " by " },
{
path: "/progfay-pub/progfay",
pathType: "root",
type: "icon",
raw: "[/progfay-pub/progfay.icon]"
}
]
},
{
indent: 1,
type: "line",
nodes: [
{
path: "/icons/github",
pathType: "root",
type: "icon",
raw: "[/icons/github.icon]"
},
{
type: "link",
raw: "[https://github.com/progfay/scrapbox-parser progfay/scrapbox-parser]",
pathType: "absolute",
href: "https://github.com/progfay/scrapbox-parser",
content: "progfay/scrapbox-parser"
}
]
},
{
indent: 1,
type: "line",
nodes: [ {
type: "plain",
raw: "かなり高頻度にメンテナンスされている",
text: "かなり高頻度にメンテナンスされている"
} ]
},
{ indent: 0, type: "line", nodes: [] },
{
indent: 0,
type: "line",
nodes: [
{
type: "plain",
raw: "Scrapbox内部で使っているparserとは若干違う",
text: "Scrapbox内部で使っているparserとは若干違う"
}
]
},
];
assertEquals(parse(text, { hasTitle: true }), expect);
});