diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2026-06-16 12:08:21 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2026-06-16 12:22:47 +0200 |
| commit | 501fdce29e4d2c46c4708ad7f44056878e0db3fa (patch) | |
| tree | db923b77037db9f5b37600a6e34c3bb2e8a971be /Tests/NorgKitTests/Models/InlineLinkTests.swift | |
Initial extraction from Norganize1.0.0
Diffstat (limited to 'Tests/NorgKitTests/Models/InlineLinkTests.swift')
| -rw-r--r-- | Tests/NorgKitTests/Models/InlineLinkTests.swift | 32 |
1 files changed, 32 insertions, 0 deletions
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) + } + } +} |