37 lines
982 B
Swift
37 lines
982 B
Swift
//
|
|
// PaymentTests.swift
|
|
// PSCB-OOS-iOSTests
|
|
//
|
|
// Created by OA on 12.10.2020.
|
|
//
|
|
|
|
import Foundation
|
|
import XCTest
|
|
|
|
@testable import PSCBOnline
|
|
|
|
final class PaymentTests: XCTestCase {
|
|
|
|
func testEncoding() {
|
|
// given:
|
|
let payment = Payment.example
|
|
let encoder = JSONEncoder()
|
|
|
|
// expect:
|
|
XCTAssertNoThrow(try encoder.encode(payment))
|
|
|
|
// when:
|
|
let json = try? encoder.encode(payment)
|
|
let string = String(data: json ?? Data(), encoding: .utf8)!
|
|
|
|
// then:
|
|
print("----")
|
|
print(string)
|
|
|
|
XCTAssertEqual(string, """
|
|
{"amount":150,"orderId":"\(payment.orderId)","recurrentable":false,"details":"Wonderful warm socks","customerAccount":"ID-12345","showOrderId":"\(payment.showOrderId!)","customerPhone":"+7 900 000 00 00","customerEmail":"foo@bar.com","customerComment":"By tomorrow please"}
|
|
""")
|
|
}
|
|
|
|
}
|