Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joemasilotti committed Dec 7, 2023
1 parent ffcc782 commit 5da2559
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Tests/MessageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class MessageTests: XCTestCase {

// MARK: Custom encoding

func test_encodingWithCustomEncoder() {
func test_encodingWithCustomEncoder() throws {
let encoder = JSONEncoder()
encoder.keyEncodingStrategy = .convertToSnakeCase
Strada.config.jsonEncoder = encoder
Expand All @@ -204,6 +204,15 @@ class MessageTests: XCTestCase {

let newMessage = message.replacing(data: messageData)

XCTAssertEqual(message, newMessage)
XCTAssertEqual(message.id, newMessage.id)
XCTAssertEqual(message.event, newMessage.event)
XCTAssertEqual(message.metadata, newMessage.metadata)

// JSON as a string might have keys in a different order. Parse values to ensure equality.
let newMessageData = try XCTUnwrap(message.jsonData.jsonObject() as? [String: String])
XCTAssertEqual(newMessageData.keys.count, 3)
XCTAssertEqual(newMessageData["title"], "Page-title")
XCTAssertEqual(newMessageData["subtitle"], "Page-subtitle")
XCTAssertEqual(newMessageData["action_name"], "go")
}
}

0 comments on commit 5da2559

Please sign in to comment.