import Foundation import Testing @testable import NorgKit struct NorgTaskTests { private let file = URL(filePath: "/tmp/notes.norg") @Test func idCombinesFileURLAndLine() { let task = NorgTask(fileURL: file, line: 7, status: .undone, text: "do it") #expect(task.id == "\(file.absoluteString):7") } @Test func idIsStableForSameFileAndLine() { let a = NorgTask(fileURL: file, line: 3, status: .done, text: "a") let b = NorgTask(fileURL: file, line: 3, status: .urgent, text: "b") #expect(a.id == b.id) } @Test func differentLinesProduceDifferentIDs() { let a = NorgTask(fileURL: file, line: 1, status: .done, text: "a") let b = NorgTask(fileURL: file, line: 2, status: .done, text: "a") #expect(a.id != b.id) } @Test func roundTripsThroughJSON() throws { let task = NorgTask(fileURL: file, line: 4, status: .pending, text: "keep") let data = try JSONEncoder().encode(task) let decoded = try JSONDecoder().decode(NorgTask.self, from: data) #expect(decoded == task) } }