Skip to content

Commit

Permalink
Add inits to WMTResultTexts and show it in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hopsaheysa committed Jun 27, 2024
1 parent 5e10f33 commit cda9f0c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,23 @@ public class WMTResultTexts: Codable {

/// Optional message to be displayed when the operation is rejected.
public let reject: String?

// MARK: - INTERNALS

private enum Keys: CodingKey {
case success, failure, reject
}

public required init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: Keys.self)
success = try? c.decode(String.self, forKey: .success)
failure = try? c.decode(String.self, forKey: .failure)
reject = try? c.decode(String.self, forKey: .reject)
}

public init(success: String?, failure: String?, reject: String?) {
self.success = success
self.failure = failure
self.reject = reject
}
}
8 changes: 5 additions & 3 deletions WultraMobileTokenSDKTests/NetworkingObjectsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,11 @@ class NetworkingObjectsTests: XCTestCase {
return
}

XCTAssertEqual(resultTexts2.success, "Payment of was confirmed")
XCTAssertEqual(resultTexts2.reject, "Payment was rejected")
XCTAssertEqual(resultTexts2.failure, "Payment approval failed")
let createdTexts = WMTResultTexts(success: "Payment of was confirmed", failure: "Payment approval failed", reject: "Payment was rejected")

XCTAssertEqual(resultTexts2.success, createdTexts.success)
XCTAssertEqual(resultTexts2.reject, createdTexts.reject)
XCTAssertEqual(resultTexts2.failure, createdTexts.failure)
}
}

Expand Down

0 comments on commit cda9f0c

Please sign in to comment.