aboutsummaryrefslogtreecommitdiff
path: root/Tests/NorgKitTests/Models/InlineSpanTests.swift
diff options
context:
space:
mode:
authorRuben Beltran del Rio <jj@r.bdr.sh>2026-06-16 12:08:21 +0200
committerRuben Beltran del Rio <jj@r.bdr.sh>2026-06-16 12:22:47 +0200
commit501fdce29e4d2c46c4708ad7f44056878e0db3fa (patch)
treedb923b77037db9f5b37600a6e34c3bb2e8a971be /Tests/NorgKitTests/Models/InlineSpanTests.swift
Initial extraction from Norganize1.0.0
Diffstat (limited to 'Tests/NorgKitTests/Models/InlineSpanTests.swift')
-rw-r--r--Tests/NorgKitTests/Models/InlineSpanTests.swift35
1 files changed, 35 insertions, 0 deletions
diff --git a/Tests/NorgKitTests/Models/InlineSpanTests.swift b/Tests/NorgKitTests/Models/InlineSpanTests.swift
new file mode 100644
index 0000000..24531e4
--- /dev/null
+++ b/Tests/NorgKitTests/Models/InlineSpanTests.swift
@@ -0,0 +1,35 @@
+import Foundation
+import Testing
+
+@testable import NorgKit
+
+struct InlineSpanTests {
+
+ @Test func defaultsToNoStyleAndNoLink() {
+ let span = InlineSpan(text: "hi")
+ #expect(span.styles.isEmpty)
+ #expect(span.link == nil)
+ }
+
+ @Test func storesStyleAndLink() {
+ let link = InlineLink(kind: .link, target: "https://example.com")
+ let span = InlineSpan(text: "hi", styles: .bold, link: link)
+ #expect(span.styles.contains(.bold))
+ #expect(span.link == link)
+ }
+
+ @Test func equatableDistinguishesFields() {
+ #expect(InlineSpan(text: "a") == InlineSpan(text: "a"))
+ #expect(InlineSpan(text: "a") != InlineSpan(text: "b"))
+ #expect(InlineSpan(text: "a", styles: .bold) != InlineSpan(text: "a"))
+ }
+
+ @Test func roundTripsThroughJSON() throws {
+ let span = InlineSpan(
+ text: "hi", styles: [.bold, .italic],
+ link: InlineLink(kind: .anchor, target: nil)
+ )
+ let data = try JSONEncoder().encode(span)
+ #expect(try JSONDecoder().decode(InlineSpan.self, from: data) == span)
+ }
+}