aboutsummaryrefslogtreecommitdiff
path: root/Tests/NorgKeyboardToolbarTests
diff options
context:
space:
mode:
authorRuben Beltran del Rio <jj@r.bdr.sh>2026-06-16 15:22:08 +0200
committerRuben Beltran del Rio <jj@r.bdr.sh>2026-06-16 15:22:08 +0200
commite5e024a5f4c8709cf2a28dc3bfab79d8037516e1 (patch)
treeb458cc77b4bbd0580ed5248e90e78148b697199c /Tests/NorgKeyboardToolbarTests
parent3402f5764f794a60f85a152a13c4eacaa2a719f6 (diff)
Support all bare modifiers1.0.0
Diffstat (limited to 'Tests/NorgKeyboardToolbarTests')
-rw-r--r--Tests/NorgKeyboardToolbarTests/EditorSnippetTests.swift38
1 files changed, 38 insertions, 0 deletions
diff --git a/Tests/NorgKeyboardToolbarTests/EditorSnippetTests.swift b/Tests/NorgKeyboardToolbarTests/EditorSnippetTests.swift
index 00a9332..a1ff135 100644
--- a/Tests/NorgKeyboardToolbarTests/EditorSnippetTests.swift
+++ b/Tests/NorgKeyboardToolbarTests/EditorSnippetTests.swift
@@ -147,4 +147,42 @@ struct EditorSnippetTests {
let result = EditorSnippet.heading.apply(to: "~ ", cursor: 2)
#expect(result.text == "~ \n* ")
}
+
+ // MARK: - Task button supports every detached modifier
+
+ @Test func taskAddsMarkerToBareUnorderedListItem() {
+ // "- |" -> "- ( ) |"
+ let result = EditorSnippet.task.apply(to: "- ", cursor: 2)
+ #expect(result.text == "- ( ) ")
+ #expect(result.cursor == 6)
+ }
+
+ @Test func taskAddsMarkerToEveryDetachedModifier() {
+ // Quotes, definitions, footnotes and the like all carry tasks per the
+ // Norg spec, matching NorgKit's task scanner.
+ for marker in [">", "$", "^", ":"] {
+ let result = EditorSnippet.task.apply(to: "\(marker) ", cursor: 2)
+ #expect(result.text == "\(marker) ( ) ")
+ #expect(result.cursor == 6)
+ }
+ }
+
+ @Test func taskAddsMarkerToNestedDetachedModifierPreservingContent() {
+ // ">> |Quote" -> ">> ( ) |Quote"
+ let result = EditorSnippet.task.apply(to: ">> Quote", cursor: 3)
+ #expect(result.text == ">> ( ) Quote")
+ #expect(result.cursor == 7)
+ }
+
+ @Test func taskIgnoresWeakDelimiterMadeOfDashes() {
+ // "---|" is a delimiter, not a list item — start a new task line instead.
+ let result = EditorSnippet.task.apply(to: "---", cursor: 3)
+ #expect(result.text == "---\n- ( ) ")
+ }
+
+ @Test func taskInsertsNewLineWhenMarkerHasNoSeparatingSpace() {
+ // A bare marker with no trailing space isn't a detached modifier yet.
+ let result = EditorSnippet.task.apply(to: ">", cursor: 1)
+ #expect(result.text == ">\n- ( ) ")
+ }
}