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/InlineStyleTests.swift | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Tests/NorgKitTests/Models/InlineStyleTests.swift (limited to 'Tests/NorgKitTests/Models/InlineStyleTests.swift') diff --git a/Tests/NorgKitTests/Models/InlineStyleTests.swift b/Tests/NorgKitTests/Models/InlineStyleTests.swift new file mode 100644 index 0000000..4eafc12 --- /dev/null +++ b/Tests/NorgKitTests/Models/InlineStyleTests.swift @@ -0,0 +1,35 @@ +import Foundation +import Testing + +@testable import NorgKit + +struct InlineStyleTests { + + @Test func combinesAndContains() { + let style: InlineStyle = [.bold, .italic] + #expect(style.contains(.bold)) + #expect(style.contains(.italic)) + #expect(!style.contains(.underline)) + } + + @Test func distinctRawValues() { + let all: [InlineStyle] = [ + .bold, .italic, .underline, .strikethrough, + .verbatim, .superscript, .subscript, .spoiler, .math, + ] + #expect(Set(all.map(\.rawValue)).count == all.count) + } + + @Test func encodesAsSingleInteger() throws { + let style: InlineStyle = [.bold, .verbatim] + let data = try JSONEncoder().encode(style) + #expect(String(data: data, encoding: .utf8) == "\(style.rawValue)") + } + + @Test func roundTripsThroughJSON() throws { + let style: InlineStyle = [.italic, .math, .spoiler] + let data = try JSONEncoder().encode(style) + let decoded = try JSONDecoder().decode(InlineStyle.self, from: data) + #expect(decoded == style) + } +} -- cgit