From decb76830c2fc6a31b16124a83f0933a87599826 Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Sun, 15 Oct 2023 15:05:12 +0300 Subject: [PATCH] Implement `RefundRequestProvider` tests --- .../RefundRequestProviderTests.swift | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Tests/FlareTests/UnitTests/Providers/RefundRequestProviderTests.swift diff --git a/Tests/FlareTests/UnitTests/Providers/RefundRequestProviderTests.swift b/Tests/FlareTests/UnitTests/Providers/RefundRequestProviderTests.swift new file mode 100644 index 000000000..6488c5ea6 --- /dev/null +++ b/Tests/FlareTests/UnitTests/Providers/RefundRequestProviderTests.swift @@ -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