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) } }