-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
RefundRequestProvider
tests
- Loading branch information
1 parent
7263836
commit decb768
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
Tests/FlareTests/UnitTests/Providers/RefundRequestProviderTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |