fchaty/FchatiApp/Tests/FchatiAppTests/WSMessageTests.swift

23 lines
584 B
Swift

import XCTest
@testable import FchatiApp
final class WSMessageTests: XCTestCase {
func testMessageRoundTripPreservesServerFields() throws {
let message = WSMessage(
type: "chat.message",
id: "message-id",
body: "Hello",
from: "peer-id",
fromName: "Alex",
sentAt: "2026-07-26T18:12:00.123Z"
)
let decodedMessage = try JSONDecoder().decode(
WSMessage.self,
from: JSONEncoder().encode(message)
)
XCTAssertEqual(decodedMessage, message)
}
}