Skip to content

Commit

Permalink
Merge pull request #327 from tangem/IOS-4927_fix_tests
Browse files Browse the repository at this point in the history
IOS-4927 Try to make tests locale independent
  • Loading branch information
tureck1y authored Nov 1, 2023
2 parents d73f7ae + 1836e08 commit 18af3a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
7 changes: 6 additions & 1 deletion TangemSdk/TangemSdk/Common/JSON/JSONStringConvertible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ public extension JSONStringConvertible {
let data = (try? JSONEncoder.tangemSdkEncoder.encode(self)) ?? Data()
return String(data: data, encoding: .utf8)!
}


var testJson: String {
let data = (try? JSONEncoder.tangemSdkTestEncoder.encode(self)) ?? Data()
return String(data: data, encoding: .utf8)!
}

func eraseToAnyResponse() -> AnyJSONRPCResponse {
AnyJSONRPCResponse(self)
}
Expand Down
13 changes: 2 additions & 11 deletions TangemSdk/TangemSdkTests/JSONRPCTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,8 @@ class JSONRPCTests: XCTestCase {
func testJsonResponse() {
let response = SuccessResponse(cardId: "c000111122223333")
let result: Result<SuccessResponse, TangemSdkError> = .success(response)
let jsonResponse = result.toJsonResponse(id: 1).json
let testResponse =
"""
{
"jsonrpc" : "2.0",
"result" : {
"cardId" : "c000111122223333"
},
"id" : 1
}
"""
let jsonResponse = result.toJsonResponse(id: 1).testJson
let testResponse = "{\"id\":1,\"jsonrpc\":\"2.0\",\"result\":{\"cardId\":\"c000111122223333\"}}"
XCTAssertEqual(jsonResponse, testResponse)
}

Expand Down
2 changes: 1 addition & 1 deletion TangemSdk/TangemSdkTests/TlvTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class TlvTests: XCTestCase {

//test dateTime
let date: Date = try! cardDataDecoder.decode(.manufactureDateTime)
let dateString = date.toString(style: .short)
let dateString = date.toString(style: .short, locale: Locale(identifier: "en_US"))
XCTAssertEqual(dateString, "7/27/18")

let dateWrong: Int? = try? cardDataDecoder.decode(.manufactureDateTime)
Expand Down

0 comments on commit 18af3a9

Please sign in to comment.