unit tests
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user