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/InlineLinkTests.swift | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Tests/NorgKitTests/Models/InlineLinkTests.swift (limited to 'Tests/NorgKitTests/Models/InlineLinkTests.swift') diff --git a/Tests/NorgKitTests/Models/InlineLinkTests.swift b/Tests/NorgKitTests/Models/InlineLinkTests.swift new file mode 100644 index 0000000..9cf2cce --- /dev/null +++ b/Tests/NorgKitTests/Models/InlineLinkTests.swift @@ -0,0 +1,32 @@ +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) + } + } +} -- cgit