From 501fdce29e4d2c46c4708ad7f44056878e0db3fa Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Tue, 16 Jun 2026 12:08:21 +0200 Subject: Initial extraction from Norganize --- Tests/NorgKitTests/Models/InlineSpanTests.swift | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Tests/NorgKitTests/Models/InlineSpanTests.swift (limited to 'Tests/NorgKitTests/Models/InlineSpanTests.swift') 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) + } +} -- cgit