Add inline text tests
This commit is contained in:
@@ -3,6 +3,7 @@ import std/[
|
||||
sugar,
|
||||
]
|
||||
import fp/[
|
||||
option,
|
||||
resultM,
|
||||
]
|
||||
import ./org_types
|
||||
@@ -58,6 +59,8 @@ proc tryTokenizeInline*(content: string): OrgInlineBuilderResult =
|
||||
# -- Tests
|
||||
|
||||
when isMainModule:
|
||||
import fp/list
|
||||
|
||||
block testParsers:
|
||||
proc testParser(str: string, parser: parserFnT): string =
|
||||
initParserResult(str).flatMap(parser).tokensToString()
|
||||
@@ -70,7 +73,29 @@ when isMainModule:
|
||||
assert testParser("+strikeThrough+", strikeThroughParser) == "strikeThrough"
|
||||
|
||||
block testTokenizers:
|
||||
let test = tryTokenizeInline(
|
||||
"Regular *bold* [[placeholder.com]] /italic/ _underline_ =verbatim= ~code~ +strikethrough+ [[https://placeholder.com][title]]"
|
||||
)
|
||||
echo test.unsafeGet()
|
||||
let testStr = "Regular *bold* [[placeholder.com]] /italic/ _underline_ =verbatim= ~code~ +strikethrough+ [[https://placeholder.com][title]]"
|
||||
let testBuilder = tryTokenizeInline(testStr)
|
||||
|
||||
assert testBuilder.isOk()
|
||||
|
||||
let testTokens = testBuilder.unsafeGet().tree
|
||||
let testTokensEpxected = @[
|
||||
OrgInlineBlock(kind: orgRawText, content: "Regular "),
|
||||
OrgInlineBlock(kind: orgBoldText, content: "bold"),
|
||||
OrgInlineBlock(kind: orgRawText, content: " "),
|
||||
OrgInlineBlock(kind: orgLink, linkUrl: "placeholder.com"),
|
||||
OrgInlineBlock(kind: orgRawText, content: " "),
|
||||
OrgInlineBlock(kind: orgItalicText, content: "italic"),
|
||||
OrgInlineBlock(kind: orgRawText, content: " "),
|
||||
OrgInlineBlock(kind: orgUnderlineText, content: "underline"),
|
||||
OrgInlineBlock(kind: orgRawText, content: " "),
|
||||
OrgInlineBlock(kind: orgVerbatimText, content: "verbatim"),
|
||||
OrgInlineBlock(kind: orgRawText, content: " "),
|
||||
OrgInlineBlock(kind: orgCodeText, content: "code"),
|
||||
OrgInlineBlock(kind: orgRawText, content: " "),
|
||||
OrgInlineBlock(kind: orgStrikeThroughText, content: "strikethrough"),
|
||||
OrgInlineBlock(kind: orgRawText, content: " "),
|
||||
OrgInlineBlock(kind: orgLink, linkDescription: "title".some(), linkUrl: "https://placeholder.com"),
|
||||
]
|
||||
|
||||
assert testTokens.asList() == testTokensEpxected.asList()
|
||||
|
||||
Reference in New Issue
Block a user