Skip to content

Commit

Permalink
Sort JSON keys in tests
Browse files Browse the repository at this point in the history
This should fix random issues with tests.
  • Loading branch information
mburumaxwell committed Jul 15, 2024
1 parent 39cde3e commit e71c9e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Tests/TingleApiClientTests/HttpApiResponseProblemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class HttpApiResponseProblemTest: XCTestCase {
problem.errors!["SessionId"] = ["The SessionId is required"]

// serialize the problem and ensure that the produced value is the same
let expectedJson = "{\"title\":\"insufficient_balance\",\"detail\":\"Add more money!\",\"errors\":{\"SessionId\":[\"The SessionId is required\"]}}"
let expectedJson = "{\"detail\":\"Add more money!\",\"errors\":{\"SessionId\":[\"The SessionId is required\"]},\"title\":\"insufficient_balance\"}"
let encoder = JSONEncoder()
encoder.outputFormatting = .sortedKeys
let data = try! encoder.encode(problem)
let actualJson = String(data: data, encoding: .utf8)!
XCTAssertEqual(expectedJson, actualJson)
Expand Down
1 change: 1 addition & 0 deletions Tests/TingleApiClientTests/JsonPatchDocumentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class JsonPatchDocumentTest: XCTestCase {

let expectedJson = "[{\"op\":\"replace\",\"path\":\"Name\",\"value\":\"Mr.Zero\"}]"
let encoder = JSONEncoder()
encoder.outputFormatting = .sortedKeys
let data = try! encoder.encode(document.getOperations())
let actualJson = String(data: data, encoding: .utf8)!
XCTAssertEqual(expectedJson, actualJson)
Expand Down

0 comments on commit e71c9e5

Please sign in to comment.