import Foundation import Testing @testable import NorgKit struct InlineLinkTests { @Test func storesKindAndTarget() { let link = InlineLink(kind: .link, target: "https://example.com") #expect(link.kind == .link) #expect(link.target == "https://example.com") } @Test func anchorMayHaveNoTarget() { let anchor = InlineLink(kind: .anchor, target: nil) #expect(anchor.kind == .anchor) #expect(anchor.target == nil) } @Test func equatableDistinguishesKindAndTarget() { #expect(InlineLink(kind: .link, target: "a") == InlineLink(kind: .link, target: "a")) #expect(InlineLink(kind: .link, target: "a") != InlineLink(kind: .anchor, target: "a")) #expect(InlineLink(kind: .link, target: "a") != InlineLink(kind: .link, target: "b")) } @Test func roundTripsThroughJSON() throws { for link in [InlineLink(kind: .link, target: "x"), InlineLink(kind: .anchor, target: nil)] { let data = try JSONEncoder().encode(link) #expect(try JSONDecoder().decode(InlineLink.self, from: data) == link) } } }