Skip to content

Commit

Permalink
[in_app_purchase_storekit] Migrate FIATransactionCacheTests.m to.Swift (
Browse files Browse the repository at this point in the history
  • Loading branch information
LouiseHsu authored Jul 19, 2024
1 parent 68b6a68 commit 3144ac0
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
F24C45E22C409D42000C6C72 /* InAppPurchasePluginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F24C45E12C409D41000C6C72 /* InAppPurchasePluginTests.swift */; };
F276940B2C47268700277144 /* ProductRequestHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F276940A2C47268700277144 /* ProductRequestHandlerTests.swift */; };
F27694112C49BF6F00277144 /* FIAPPaymentQueueDeleteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694102C49BF6F00277144 /* FIAPPaymentQueueDeleteTests.swift */; };
F27694172C49DBCA00277144 /* FIATransactionCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694162C49DBCA00277144 /* FIATransactionCacheTests.swift */; };
F295AD3A2C1256DD0067C78A /* Stubs.m in Sources */ = {isa = PBXBuildFile; fileRef = F295AD392C1256DD0067C78A /* Stubs.m */; };
F295AD442C1256F50067C78A /* FIATransactionCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F295AD3E2C1256F50067C78A /* FIATransactionCacheTests.m */; };
F295AD452C1256F50067C78A /* PaymentQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F295AD3F2C1256F50067C78A /* PaymentQueueTests.m */; };
F295AD462C1256F50067C78A /* TranslatorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F295AD402C1256F50067C78A /* TranslatorTests.m */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -78,9 +78,9 @@
F24C45E12C409D41000C6C72 /* InAppPurchasePluginTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = InAppPurchasePluginTests.swift; path = ../../shared/RunnerTests/InAppPurchasePluginTests.swift; sourceTree = "<group>"; };
F276940A2C47268700277144 /* ProductRequestHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProductRequestHandlerTests.swift; path = ../../shared/RunnerTests/ProductRequestHandlerTests.swift; sourceTree = "<group>"; };
F27694102C49BF6F00277144 /* FIAPPaymentQueueDeleteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FIAPPaymentQueueDeleteTests.swift; path = ../../shared/RunnerTests/FIAPPaymentQueueDeleteTests.swift; sourceTree = "<group>"; };
F27694162C49DBCA00277144 /* FIATransactionCacheTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FIATransactionCacheTests.swift; path = ../../shared/RunnerTests/FIATransactionCacheTests.swift; sourceTree = "<group>"; };
F295AD362C1251300067C78A /* Stubs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stubs.h; path = ../../shared/RunnerTests/Stubs.h; sourceTree = "<group>"; };
F295AD392C1256DD0067C78A /* Stubs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Stubs.m; path = ../../shared/RunnerTests/Stubs.m; sourceTree = "<group>"; };
F295AD3E2C1256F50067C78A /* FIATransactionCacheTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FIATransactionCacheTests.m; path = ../../shared/RunnerTests/FIATransactionCacheTests.m; sourceTree = "<group>"; };
F295AD3F2C1256F50067C78A /* PaymentQueueTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PaymentQueueTests.m; path = ../../shared/RunnerTests/PaymentQueueTests.m; sourceTree = "<group>"; };
F295AD402C1256F50067C78A /* TranslatorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TranslatorTests.m; path = ../../shared/RunnerTests/TranslatorTests.m; sourceTree = "<group>"; };
F6E5D5F926131C4800C68BED /* Configuration.storekit */ = {isa = PBXFileReference; lastKnownFileType = text; path = Configuration.storekit; sourceTree = "<group>"; };
Expand Down Expand Up @@ -186,10 +186,10 @@
A59001A521E69658004A3E5E /* RunnerTests */ = {
isa = PBXGroup;
children = (
F27694162C49DBCA00277144 /* FIATransactionCacheTests.swift */,
F27694102C49BF6F00277144 /* FIAPPaymentQueueDeleteTests.swift */,
F24C45E12C409D41000C6C72 /* InAppPurchasePluginTests.swift */,
F276940A2C47268700277144 /* ProductRequestHandlerTests.swift */,
F295AD3E2C1256F50067C78A /* FIATransactionCacheTests.m */,
F295AD3F2C1256F50067C78A /* PaymentQueueTests.m */,
F295AD402C1256F50067C78A /* TranslatorTests.m */,
F295AD392C1256DD0067C78A /* Stubs.m */,
Expand Down Expand Up @@ -436,10 +436,10 @@
F24C45E22C409D42000C6C72 /* InAppPurchasePluginTests.swift in Sources */,
F22BF91C2BC9B40B00713878 /* SwiftStubs.swift in Sources */,
F295AD452C1256F50067C78A /* PaymentQueueTests.m in Sources */,
F295AD442C1256F50067C78A /* FIATransactionCacheTests.m in Sources */,
F276940B2C47268700277144 /* ProductRequestHandlerTests.swift in Sources */,
F295AD462C1256F50067C78A /* TranslatorTests.m in Sources */,
F295AD3A2C1256DD0067C78A /* Stubs.m in Sources */,
F27694172C49DBCA00277144 /* FIATransactionCacheTests.swift in Sources */,
F27694112C49BF6F00277144 /* FIAPPaymentQueueDeleteTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
F24C45E42C409D87000C6C72 /* InAppPurchasePluginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F24C45E32C409D87000C6C72 /* InAppPurchasePluginTests.swift */; };
F27694092C4724B200277144 /* ProductRequestHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694082C4724B200277144 /* ProductRequestHandlerTests.swift */; };
F27694132C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694122C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift */; };
F27694192C49DBE800277144 /* FIATransactionCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694182C49DBE800277144 /* FIATransactionCacheTests.swift */; };
F2C3A7412BD9D33D000D35F2 /* Stubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2C3A7402BD9D33D000D35F2 /* Stubs.swift */; };
F79BDC122905FBF700E3999D /* FIATransactionCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F79BDC112905FBF700E3999D /* FIATransactionCacheTests.m */; };
F79BDC182905FC1800E3999D /* PaymentQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F79BDC172905FC1800E3999D /* PaymentQueueTests.m */; };
F79BDC1C2905FC3200E3999D /* Stubs.m in Sources */ = {isa = PBXBuildFile; fileRef = F79BDC1B2905FC3200E3999D /* Stubs.m */; };
F79BDC1E2905FC3900E3999D /* TranslatorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F79BDC1D2905FC3900E3999D /* TranslatorTests.m */; };
Expand Down Expand Up @@ -94,10 +94,10 @@
F24C45E32C409D87000C6C72 /* InAppPurchasePluginTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = InAppPurchasePluginTests.swift; path = ../../shared/RunnerTests/InAppPurchasePluginTests.swift; sourceTree = "<group>"; };
F27694082C4724B200277144 /* ProductRequestHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProductRequestHandlerTests.swift; path = ../../shared/RunnerTests/ProductRequestHandlerTests.swift; sourceTree = "<group>"; };
F27694122C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FIAPPaymentQueueDeleteTests.swift; path = ../../shared/RunnerTests/FIAPPaymentQueueDeleteTests.swift; sourceTree = "<group>"; };
F27694182C49DBE800277144 /* FIATransactionCacheTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FIATransactionCacheTests.swift; path = ../../shared/RunnerTests/FIATransactionCacheTests.swift; sourceTree = "<group>"; };
F2C3A73F2BD9D33D000D35F2 /* RunnerTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RunnerTests-Bridging-Header.h"; sourceTree = "<group>"; };
F2C3A7402BD9D33D000D35F2 /* Stubs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stubs.swift; sourceTree = "<group>"; };
F700DD0228E652A10004836B /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
F79BDC112905FBF700E3999D /* FIATransactionCacheTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FIATransactionCacheTests.m; path = ../../shared/RunnerTests/FIATransactionCacheTests.m; sourceTree = "<group>"; };
F79BDC152905FC0500E3999D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../../shared/RunnerTests/Info.plist; sourceTree = "<group>"; };
F79BDC172905FC1800E3999D /* PaymentQueueTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PaymentQueueTests.m; path = ../../shared/RunnerTests/PaymentQueueTests.m; sourceTree = "<group>"; };
F79BDC1B2905FC3200E3999D /* Stubs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Stubs.m; path = ../../shared/RunnerTests/Stubs.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -217,6 +217,7 @@
F700DD0328E652A10004836B /* RunnerTests */ = {
isa = PBXGroup;
children = (
F27694182C49DBE800277144 /* FIATransactionCacheTests.swift */,
F27694122C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift */,
F24C45E32C409D87000C6C72 /* InAppPurchasePluginTests.swift */,
F27694082C4724B200277144 /* ProductRequestHandlerTests.swift */,
Expand All @@ -225,7 +226,6 @@
F79BDC152905FC0500E3999D /* Info.plist */,
F79BDC1B2905FC3200E3999D /* Stubs.m */,
F79BDC1D2905FC3900E3999D /* TranslatorTests.m */,
F79BDC112905FBF700E3999D /* FIATransactionCacheTests.m */,
F2C3A7402BD9D33D000D35F2 /* Stubs.swift */,
F2C3A73F2BD9D33D000D35F2 /* RunnerTests-Bridging-Header.h */,
);
Expand Down Expand Up @@ -468,8 +468,8 @@
F79BDC182905FC1800E3999D /* PaymentQueueTests.m in Sources */,
F79BDC1C2905FC3200E3999D /* Stubs.m in Sources */,
F27694092C4724B200277144 /* ProductRequestHandlerTests.swift in Sources */,
F79BDC122905FBF700E3999D /* FIATransactionCacheTests.m in Sources */,
F2C3A7412BD9D33D000D35F2 /* Stubs.swift in Sources */,
F27694192C49DBE800277144 /* FIATransactionCacheTests.swift in Sources */,
F27694132C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import XCTest

@testable import in_app_purchase_storekit

final class FIATransactionCacheTests: XCTestCase {

func testAddObjectsForNewKey() throws {
let dummyArray = [1, 2, 3]
let cache = FIATransactionCache()
cache.add(dummyArray, for: TransactionCacheKey.updatedTransactions)

let updatedTransactions = try XCTUnwrap(
cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as? [Int])
XCTAssertEqual(dummyArray, updatedTransactions)
}

func testAddObjectsForExistingKey() throws {
let dummyArray = [1, 2, 3]
let cache = FIATransactionCache()
cache.add(dummyArray, for: TransactionCacheKey.updatedTransactions)

let firstUpdatedTransactions = try XCTUnwrap(
cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as? [Int])
XCTAssertEqual(dummyArray, firstUpdatedTransactions)

cache.add([4, 5, 6], for: TransactionCacheKey.updatedTransactions)

let expected = [1, 2, 3, 4, 5, 6]
let secondUpdatedTransactions = try XCTUnwrap(
cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as? [Int])
XCTAssertEqual(expected, secondUpdatedTransactions)
}

func testGetObjectsForNonExistingKey() {
let cache = FIATransactionCache()
XCTAssertTrue(cache.getObjectsFor(TransactionCacheKey.updatedTransactions).isEmpty)
}

func testClear() throws {
let fakeUpdatedTransactions = [1, 2, 3]
let fakeRemovedTransactions = ["Remove 1", "Remove 2", "Remove 3"]
let fakeUpdatedDownloads = ["Download 1", "Download 2"]
let cache = FIATransactionCache()

cache.add(fakeUpdatedTransactions, for: TransactionCacheKey.updatedTransactions)
cache.add(fakeRemovedTransactions, for: TransactionCacheKey.removedTransactions)
cache.add(fakeUpdatedDownloads, for: TransactionCacheKey.updatedDownloads)

let updatedTransactions = try XCTUnwrap(
cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as? [Int])
let removedTransactions = try XCTUnwrap(
cache.getObjectsFor(TransactionCacheKey.removedTransactions) as? [String])
let updatedDownloads = try XCTUnwrap(
cache.getObjectsFor(TransactionCacheKey.updatedDownloads) as? [String])

XCTAssertEqual(fakeUpdatedTransactions, updatedTransactions)
XCTAssertEqual(fakeRemovedTransactions, removedTransactions)
XCTAssertEqual(fakeUpdatedDownloads, updatedDownloads)

cache.clear()

XCTAssertTrue(cache.getObjectsFor(TransactionCacheKey.updatedTransactions).isEmpty)
XCTAssertTrue(cache.getObjectsFor(TransactionCacheKey.removedTransactions).isEmpty)
XCTAssertTrue(cache.getObjectsFor(TransactionCacheKey.updatedDownloads).isEmpty)
}
}

0 comments on commit 3144ac0

Please sign in to comment.