diff options
Diffstat (limited to 'Tests/NorgKitTests/Models/InlineStyleTests.swift')
| -rw-r--r-- | Tests/NorgKitTests/Models/InlineStyleTests.swift | 35 |
1 files changed, 35 insertions, 0 deletions
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) + } +} |