Skip to content

Commit

Permalink
Implement RefundRequestProvider tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ns-vasilev committed Oct 15, 2023
1 parent 7263836 commit decb768
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
//

@testable import Flare
import XCTest

#if os(iOS) || VISION_OS

@available(iOS 15.0, *)
final class RefundRequestProviderTests: XCTestCase {
// MARK: Proeprties

private var sut: RefundRequestProvider!

// MARK: XCTestCase

override func setUp() {
super.setUp()
sut = RefundRequestProvider()
}

override func tearDown() {
sut = nil
super.tearDown()
}

// MARK: Tests

@MainActor
func test_thatRefundRequestProviderThrowsAnUnknownError_whenRequestDidFailed() async throws {
// given
let windowScene = WindowSceneFactory.makeWindowScene()

// when
let status = try await sut.beginRefundRequest(
transactionID: .transactionID,
windowScene: windowScene
)

// then
if case let .failure(error) = status {
XCTAssertEqual(error as NSError, IAPError.refund(error: .failed) as NSError)
} else {
XCTFail("state must be `failure`")
}
}
}

// MARK: - Constants

private extension UInt64 {
static let transactionID: UInt64 = 0
}

private extension String {
static let productID: String = "product_id"
}

#endif

0 comments on commit decb768

Please sign in to comment.