29 lines
886 B
Swift
29 lines
886 B
Swift
import Foundation
|
|
import Testing
|
|
|
|
@testable import Peered
|
|
|
|
@Suite
|
|
struct NoteContentCodableTests {
|
|
@Test("encode → decode")
|
|
func coding() throws {
|
|
let original = NoteInvitation.NoteContent(
|
|
title: "My note", noteSnapshot: "Note Sample Snapshot")
|
|
let data = try JSONEncoder().encode(original)
|
|
let decoded = try JSONDecoder().decode(NoteInvitation.NoteContent.self, from: data)
|
|
|
|
#expect(decoded.title == original.title)
|
|
#expect(decoded.noteSnapshot == original.noteSnapshot)
|
|
}
|
|
|
|
@Test
|
|
func containsExpectedKeys() throws {
|
|
let content = NoteInvitation.NoteContent(title: "Titlee", noteSnapshot: "Snapshott")
|
|
let data = try JSONEncoder().encode(content)
|
|
let json = try #require(try? JSONSerialization.jsonObject(with: data) as? [String: String])
|
|
|
|
#expect(json["title"] == "Titlee")
|
|
#expect(json["noteSnapshot"] == "Snapshott")
|
|
}
|
|
}
|