Add inline text tests
This commit is contained in:
@@ -3,6 +3,7 @@ import std/[
|
|||||||
sugar,
|
sugar,
|
||||||
]
|
]
|
||||||
import fp/[
|
import fp/[
|
||||||
|
option,
|
||||||
resultM,
|
resultM,
|
||||||
]
|
]
|
||||||
import ./org_types
|
import ./org_types
|
||||||
@@ -58,6 +59,8 @@ proc tryTokenizeInline*(content: string): OrgInlineBuilderResult =
|
|||||||
# -- Tests
|
# -- Tests
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
|
import fp/list
|
||||||
|
|
||||||
block testParsers:
|
block testParsers:
|
||||||
proc testParser(str: string, parser: parserFnT): string =
|
proc testParser(str: string, parser: parserFnT): string =
|
||||||
initParserResult(str).flatMap(parser).tokensToString()
|
initParserResult(str).flatMap(parser).tokensToString()
|
||||||
@@ -70,7 +73,29 @@ when isMainModule:
|
|||||||
assert testParser("+strikeThrough+", strikeThroughParser) == "strikeThrough"
|
assert testParser("+strikeThrough+", strikeThroughParser) == "strikeThrough"
|
||||||
|
|
||||||
block testTokenizers:
|
block testTokenizers:
|
||||||
let test = tryTokenizeInline(
|
let testStr = "Regular *bold* [[placeholder.com]] /italic/ _underline_ =verbatim= ~code~ +strikethrough+ [[https://placeholder.com][title]]"
|
||||||
"Regular *bold* [[placeholder.com]] /italic/ _underline_ =verbatim= ~code~ +strikethrough+ [[https://placeholder.com][title]]"
|
let testBuilder = tryTokenizeInline(testStr)
|
||||||
)
|
|
||||||
echo test.unsafeGet()
|
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