-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChargeRepositoryImplementationTests.swift
More file actions
38 lines (31 loc) · 1.56 KB
/
ChargeRepositoryImplementationTests.swift
File metadata and controls
38 lines (31 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import XCTest
import PaystackCore
@testable import PaystackUI
final class ChargeRepositoryImplementationTests: PSTestCase {
let apiKey = "testsk_Example"
var serviceUnderTest: ChargeRepositoryImplementation!
var paystack: Paystack!
override func setUpWithError() throws {
try super.setUpWithError()
paystack = try PaystackBuilder.newInstance.setKey(apiKey).build()
PaystackContainer.instance.store(paystack)
serviceUnderTest = ChargeRepositoryImplementation()
}
func testVerifyAccessCodeRetrievesAccessCodeAndMapsToModel() async throws {
mockServiceExecutor
.expectURL("https://api.paystack.co/transaction/verify_code/access_code_test")
.expectMethod(.get)
.expectHeader("Authorization", "Bearer \(apiKey)")
.andReturn(json: "VerifyAccessCode")
let result = try await serviceUnderTest.verifyAccessCode("access_code_test")
let expectedResult = VerifyAccessCode(amount: 10000,
currency: "NGN",
accessCode: "Access_Code_Test",
paymentChannels: [.card, .qr, .ussd, .mobileMoney],
domain: .test,
merchantName: "Test Merchant",
publicEncryptionKey: "test_encryption_key",
reference: "203520101")
XCTAssertEqual(result, expectedResult)
}
}