Tests/OrgCoreTests/CaptureScheduleTests.swift
36 lines · 1432 bytes
1import Testing
2@testable import OrgCore
3
4struct CaptureScheduleTests {
5 static let day = Days.absolute(year: 2026, month: 10, day: 9)
6
7 @Test func addsPlanningLineAfterHeading() {
8 let text = "* TODO \n body"
9 let result = Capture.scheduling(text, cursor: 7, on: Self.day)
10 #expect(result.text == "* TODO \nSCHEDULED: <2026-10-09 Fri>\n body")
11 #expect(result.cursor == 7)
12 }
13
14 @Test func headingAlone() {
15 let result = Capture.scheduling("* TODO ", cursor: 7, on: Self.day)
16 #expect(result.text == "* TODO \nSCHEDULED: <2026-10-09 Fri>")
17 #expect(result.cursor == 7)
18 }
19
20 @Test func cursorInBodyMoves() {
21 let text = "* TODO x\n"
22 let result = Capture.scheduling(text, cursor: 9, on: Self.day)
23 #expect(result.text == "* TODO x\nSCHEDULED: <2026-10-09 Fri>\n")
24 #expect(result.cursor == 9 + 28)
25 }
26
27 @Test func joinsExistingPlanningLine() {
28 let result = Capture.scheduling("* DONE x\nCLOSED: [2026-10-01 Thu]\n", cursor: 0, on: Self.day)
29 #expect(result.text == "* DONE x\nCLOSED: [2026-10-01 Thu] SCHEDULED: <2026-10-09 Fri>\n")
30 }
31
32 @Test func leavesDatedAndNonEntries() {
33 #expect(Capture.scheduling("* TODO x\n<2026-10-09 Fri>", cursor: 0, on: Self.day).text == "* TODO x\n<2026-10-09 Fri>")
34 #expect(Capture.scheduling("- [ ] item", cursor: 0, on: Self.day).text == "- [ ] item")
35 }
36}