mirror of
https://github.com/sbrow/thor.git
synced 2026-08-26 11:23:32 -04:00
test: Added tests for sectionate extension.
This commit is contained in:
@@ -45,6 +45,8 @@
|
|||||||
- [ ] Use spall to find ways to reduce run time.
|
- [ ] Use spall to find ways to reduce run time.
|
||||||
- [ ] warn/error when unknown key used in mustache.
|
- [ ] warn/error when unknown key used in mustache.
|
||||||
- [ ] Import/export packages. Hugo, jekyll, WordPress, etc.
|
- [ ] Import/export packages. Hugo, jekyll, WordPress, etc.
|
||||||
|
- [ ] Markdown
|
||||||
|
- [ ] Add overloads for every extension - accept ^strings.Builder.
|
||||||
- [ ] Review every file in thor
|
- [ ] Review every file in thor
|
||||||
- [ ] Review assets.odin
|
- [ ] Review assets.odin
|
||||||
- [ ] Review content.odin
|
- [ ] Review content.odin
|
||||||
@@ -55,12 +57,14 @@
|
|||||||
- [ ] Review minify.odin
|
- [ ] Review minify.odin
|
||||||
- [ ] Review `markdown/`
|
- [ ] Review `markdown/`
|
||||||
- [ ] Review alerts.odin
|
- [ ] Review alerts.odin
|
||||||
- [ ] Review emoji.odin
|
- [x] Review emoji.odin
|
||||||
|
- [x] Review emoji_test.odin
|
||||||
- [ ] Review footnotes.odin
|
- [ ] Review footnotes.odin
|
||||||
- [ ] Review footnotes_test.odin
|
- [ ] Review footnotes_test.odin
|
||||||
- [ ] Review highlight.odin
|
- [ ] Review highlight.odin
|
||||||
- [ ] Review markdown.odin
|
- [ ] Review markdown.odin
|
||||||
- [ ] Review sectionate.odin
|
- [x] Review sectionate.odin
|
||||||
|
- [x] Review sectionate_test.odin
|
||||||
- [ ] Review render.odin
|
- [ ] Review render.odin
|
||||||
- [x] Review site.odin
|
- [x] Review site.odin
|
||||||
- [ ] Review treesitter/treesitter.odin
|
- [ ] Review treesitter/treesitter.odin
|
||||||
|
|||||||
@@ -4,17 +4,19 @@ package markdown
|
|||||||
import "core:testing"
|
import "core:testing"
|
||||||
|
|
||||||
@(test)
|
@(test)
|
||||||
test_basic_expansion :: proc(t: ^testing.T) {
|
test_basic_emoji_expansion_works :: proc(t: ^testing.T) {
|
||||||
testing.expect_value(t, expand_emoji(":smile:"), "😄")
|
testing.expect_value(t, expand_emoji(":smile:"), "😄")
|
||||||
testing.expect_value(t, expand_emoji(":smile: :heart:"), "😄 ❤️")
|
testing.expect_value(t, expand_emoji(":smile: :heart:"), "😄 ❤️")
|
||||||
testing.expect_value(t, expand_emoji(":smile::heart:"), "😄❤️")
|
testing.expect_value(t, expand_emoji(":smile::heart:"), "😄❤️")
|
||||||
testing.expect_value(t, expand_emoji("Hello :wave:!"), "Hello 👋!")
|
testing.expect_value(t, expand_emoji("Hello :wave:!"), "Hello 👋!")
|
||||||
testing.expect_value(t, expand_emoji(":smile: rest"), "😄 rest")
|
testing.expect_value(t, expand_emoji(":smile: rest"), "😄 rest")
|
||||||
testing.expect_value(t, expand_emoji("rest :smile:"), "rest 😄")
|
testing.expect_value(t, expand_emoji("rest :smile:"), "rest 😄")
|
||||||
|
testing.expect_value(t, expand_emoji(":100:"), "💯")
|
||||||
|
testing.expect_value(t, expand_emoji(":stuck_out_tongue:"), "😛")
|
||||||
}
|
}
|
||||||
|
|
||||||
@(test)
|
@(test)
|
||||||
test_no_match :: proc(t: ^testing.T) {
|
test_emoji_skips_non_matches :: proc(t: ^testing.T) {
|
||||||
testing.expect_value(t, expand_emoji("Hello world"), "Hello world")
|
testing.expect_value(t, expand_emoji("Hello world"), "Hello world")
|
||||||
testing.expect_value(t, expand_emoji("Hello:"), "Hello:")
|
testing.expect_value(t, expand_emoji("Hello:"), "Hello:")
|
||||||
testing.expect_value(t, expand_emoji(":notreal:"), ":notreal:")
|
testing.expect_value(t, expand_emoji(":notreal:"), ":notreal:")
|
||||||
@@ -23,14 +25,9 @@ test_no_match :: proc(t: ^testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@(test)
|
@(test)
|
||||||
test_invalid_shortcodes :: proc(t: ^testing.T) {
|
test_emoji_skips_invalid_shortcodes :: proc(t: ^testing.T) {
|
||||||
testing.expect_value(t, expand_emoji("::"), "::")
|
testing.expect_value(t, expand_emoji("::"), "::")
|
||||||
testing.expect_value(t, expand_emoji(":Smile:"), ":Smile:")
|
testing.expect_value(t, expand_emoji(":Smile:"), ":Smile:")
|
||||||
testing.expect_value(t, expand_emoji(": not real :"), ": not real :")
|
testing.expect_value(t, expand_emoji(": not real :"), ": not real :")
|
||||||
}
|
}
|
||||||
|
|
||||||
@(test)
|
|
||||||
test_valid_formats :: proc(t: ^testing.T) {
|
|
||||||
testing.expect_value(t, expand_emoji(":100:"), "💯")
|
|
||||||
testing.expect_value(t, expand_emoji(":stuck_out_tongue:"), "😛")
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -37,8 +37,10 @@ wrap_sections :: proc(html: string) -> string {
|
|||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
if found {
|
||||||
|
return strings.to_string(sb)
|
||||||
|
} else {
|
||||||
return html
|
return html
|
||||||
}
|
}
|
||||||
return strings.to_string(sb)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#+test
|
||||||
|
package markdown
|
||||||
|
|
||||||
|
import "core:testing"
|
||||||
|
|
||||||
|
@(test)
|
||||||
|
test_wrap_sections_works :: proc(t: ^testing.T) {
|
||||||
|
testing.expect_value(
|
||||||
|
t,
|
||||||
|
wrap_sections("<p>intro</p><h2>Title</h2><p>body</p>"),
|
||||||
|
"<section><p>intro</p></section><section><h2>Title</h2><p>body</p></section>",
|
||||||
|
)
|
||||||
|
|
||||||
|
testing.expect_value(
|
||||||
|
t,
|
||||||
|
wrap_sections("<p>a</p><h2>A</h2><p>b</p><h2>B</h2><p>c</p>"),
|
||||||
|
"<section><p>a</p></section><section><h2>A</h2><p>b</p></section><section><h2>B</h2><p>c</p></section>",
|
||||||
|
)
|
||||||
|
|
||||||
|
testing.expect_value(
|
||||||
|
t,
|
||||||
|
wrap_sections("<h2>Title</h2><p>body</p>"),
|
||||||
|
"<section><h2>Title</h2><p>body</p></section>",
|
||||||
|
)
|
||||||
|
|
||||||
|
testing.expect_value(
|
||||||
|
t,
|
||||||
|
wrap_sections("<p>intro</p><h2>Title</h2>"),
|
||||||
|
"<section><p>intro</p></section><section><h2>Title</h2></section>",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@(test)
|
||||||
|
test_wrap_sections_doesnt_split_content :: proc(t: ^testing.T) {
|
||||||
|
testing.expect_value(
|
||||||
|
t,
|
||||||
|
wrap_sections("<p>just text</p>"),
|
||||||
|
"<section><p>just text</p></section>",
|
||||||
|
)
|
||||||
|
|
||||||
|
testing.expect_value(t, wrap_sections(""), "")
|
||||||
|
|
||||||
|
testing.expect_value(
|
||||||
|
t,
|
||||||
|
wrap_sections("<h1>Big</h1><h3>Small</h3>"),
|
||||||
|
"<section><h1>Big</h1><h3>Small</h3></section>",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user