mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
## Motivation: There is no way to run code statically like in Obj-C using `+ [NSObject initialize]`, so this ensures (through a new `SwiftLint` rule) that all test classes inherit this common test class instead of `XCTestCase` directly. A future PR will make use of this new `CIRCLECI_TESTS_GENERATE_SNAPSHOTS` environment variable to allow regenerating snapshots in CI. I've also moved the duplicated `CurrentTestCaseTracker` usages to a single point.
44 lines
1.3 KiB
Swift
44 lines
1.3 KiB
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// SKPaymentTransactionExtensionsTests.swift
|
|
//
|
|
// Created by Juanpe Catalán on 3/8/21.
|
|
|
|
import Nimble
|
|
@testable import RevenueCat
|
|
import StoreKit
|
|
import XCTest
|
|
|
|
class SKPaymentTransactionExtensionsTests: TestCase {
|
|
|
|
func testNilProductIdentifierIfPaymentIsMissing() {
|
|
let transaction = SKPaymentTransaction()
|
|
expect(transaction.productIdentifier).to(beNil())
|
|
}
|
|
|
|
func testNilProductIdentifierIfPaymentDoesNotHaveProductIdenfier() {
|
|
let transaction = MockTransaction()
|
|
transaction.mockPayment = SKPayment()
|
|
|
|
expect(transaction.productIdentifier).to(beNil())
|
|
}
|
|
|
|
func testProductIdentifierFromAnyTransaction() {
|
|
let expectedProductIdentifier = "com.product.id1"
|
|
let product = MockSK1Product(mockProductIdentifier: expectedProductIdentifier)
|
|
let payment = SKPayment(product: product)
|
|
let transaction = MockTransaction()
|
|
transaction.mockPayment = payment
|
|
|
|
expect(transaction.productIdentifier).to(equal(expectedProductIdentifier))
|
|
}
|
|
|
|
}
|