Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add swift tests #78

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,28 @@ jobs:
- name: Build example for iOS
run: |
yarn turbo run build:ios

test-ios:
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Install cocoapods
run: |
cd example/ios
pod install
env:
NO_FLIPPER: 1

- name: Clear DerivedData
run: |
rm -rf ~/Library/Developer/Xcode/DerivedData

- name: run tests
run: |
cd example/ios
xcodebuild -workspace TicketmasterIgniteExample.xcworkspace -scheme TicketmasterIgniteExample -destination 'platform=iOS Simulator,name=iPhone 16' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED=NO clean test
24 changes: 24 additions & 0 deletions example/ios/TestPlan.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"configurations" : [
{
"id" : "56E8F040-1EDF-4F87-9FCA-4B453EDE47E1",
"name" : "Configuration 1",
"options" : {

}
}
],
"defaultOptions" : {
"testTimeoutsEnabled" : true
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:TicketmasterIgniteExample.xcodeproj",
"identifier" : "00E356ED1AD99517003FC87E",
"name" : "TicketmasterIgniteExampleTests"
}
}
],
"version" : 1
}
29 changes: 17 additions & 12 deletions example/ios/TicketmasterIgniteExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
00E356F31AD99517003FC87E /* TicketmasterIgniteExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* TicketmasterIgniteExampleTests.m */; };
0C80B921A6F3F58F76C31292 /* libPods-TicketmasterIgniteExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DCACB8F33CDC322A6C60F78 /* libPods-TicketmasterIgniteExample.a */; };
0D48C3D82D02FAA30001158F /* MarketDomainTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D48C3D72D02FAA30001158F /* MarketDomainTests.swift */; };
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
Expand All @@ -30,7 +30,8 @@
/* Begin PBXFileReference section */
00E356EE1AD99517003FC87E /* TicketmasterIgniteExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TicketmasterIgniteExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
00E356F21AD99517003FC87E /* TicketmasterIgniteExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TicketmasterIgniteExampleTests.m; sourceTree = "<group>"; };
0D48C3D62D02FAA30001158F /* TicketmasterIgniteExampleTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TicketmasterIgniteExampleTests-Bridging-Header.h"; sourceTree = "<group>"; };
0D48C3D72D02FAA30001158F /* MarketDomainTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketDomainTests.swift; sourceTree = "<group>"; };
13B07F961A680F5B00A75B9A /* TicketmasterIgniteExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TicketmasterIgniteExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = TicketmasterIgniteExample/AppDelegate.h; sourceTree = "<group>"; };
13B07FB01A68108700A75B9A /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppDelegate.mm; path = TicketmasterIgniteExample/AppDelegate.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -72,8 +73,9 @@
00E356EF1AD99517003FC87E /* TicketmasterIgniteExampleTests */ = {
isa = PBXGroup;
children = (
00E356F21AD99517003FC87E /* TicketmasterIgniteExampleTests.m */,
00E356F01AD99517003FC87E /* Supporting Files */,
0D48C3D72D02FAA30001158F /* MarketDomainTests.swift */,
0D48C3D62D02FAA30001158F /* TicketmasterIgniteExampleTests-Bridging-Header.h */,
);
path = TicketmasterIgniteExampleTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -208,6 +210,7 @@
TargetAttributes = {
00E356ED1AD99517003FC87E = {
CreatedOnToolsVersion = 6.2;
LastSwiftMigration = 1610;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
13B07F861A680F5B00A75B9A = {
Expand Down Expand Up @@ -390,7 +393,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
00E356F31AD99517003FC87E /* TicketmasterIgniteExampleTests.m in Sources */,
0D48C3D82D02FAA30001158F /* MarketDomainTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -419,6 +422,7 @@
baseConfigurationReference = 5B7EB9410499542E8C5724F5 /* Pods-TicketmasterIgniteExample-TicketmasterIgniteExampleTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ENABLE_MODULES = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
Expand All @@ -437,6 +441,9 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "TicketmasterIgniteExampleTests/TicketmasterIgniteExampleTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TicketmasterIgniteExample.app/TicketmasterIgniteExample";
};
name = Debug;
Expand All @@ -446,6 +453,7 @@
baseConfigurationReference = 89C6BE57DB24E9ADA2F236DE /* Pods-TicketmasterIgniteExample-TicketmasterIgniteExampleTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ENABLE_MODULES = YES;
COPY_PHASE_STRIP = NO;
INFOPLIST_FILE = TicketmasterIgniteExampleTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
Expand All @@ -461,6 +469,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "TicketmasterIgniteExampleTests/TicketmasterIgniteExampleTests-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TicketmasterIgniteExample.app/TicketmasterIgniteExample";
};
name = Release;
Expand Down Expand Up @@ -591,12 +601,10 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
OTHER_LDFLAGS = "$(inherited) ";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
USE_HERMES = true;
};
name = Debug;
Expand Down Expand Up @@ -667,10 +675,7 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
OTHER_LDFLAGS = "$(inherited) ";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
Expand Down
31 changes: 31 additions & 0 deletions example/ios/TicketmasterIgniteExampleTests/MarketDomainTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// SampleTest.swift
// TicketmasterIgniteExampleTests
//
// Created by justyna zygmunt on 06/12/2024.
//
import XCTest
import TicketmasterFoundation
@testable import react_native_ticketmaster_ignite

class MarketDomainObjectTests: XCTestCase {
let marketDomainObject = MarketDomainObject()

func testGetMarketDomainReturnsCorrectDomainForUs() {
let domain = marketDomainObject.getMarketDomain(marketDomainConfig: "US")

XCTAssertEqual(domain, MarketDomain.US, "getMarketDomain should return the correct domain for 'us'.")
}

func testGetMarketDomainReturnsCorrectDomainForAU() {
let domain = marketDomainObject.getMarketDomain(marketDomainConfig: "AU")

XCTAssertEqual(domain, MarketDomain.AU, "getMarketDomain should return the correct domain for 'AU'.")
}

func testGetMarketDomainReturnsCorrectDomainWhenEmptyStringPassed() {
let domain = marketDomainObject.getMarketDomain(marketDomainConfig: "")

XCTAssertEqual(domain, MarketDomain.US, "getMarketDomain should return US domain for empty strings.")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

This file was deleted.

8 changes: 3 additions & 5 deletions ios/MarketDomain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import TicketmasterFoundation

class MarketDomainObject {
static let shared = MarketDomainObject()

let marketDomain = Config.shared.get(for: "marketDomain")

func getMarketDomain() -> TicketmasterFoundation.MarketDomain {
return MarketDomain(countryCode: marketDomain.lowercased()) ?? MarketDomain.US

func getMarketDomain(marketDomainConfig: String) -> TicketmasterFoundation.MarketDomain {
return MarketDomain(countryCode: marketDomainConfig.lowercased()) ?? MarketDomain.US
}
}
3 changes: 2 additions & 1 deletion ios/PrePurchaseSDK+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ extension PrePurchaseSDK: TMPrePurchaseNavigationDelegate, TMPrePurchaseAnalytic
let apiKey = Config.shared.get(for: "apiKey")
let region = Config.shared.get(for: "region")
let primaryColor = Config.shared.get(for: "primaryColor")
let marketDomainConfig = Config.shared.get(for: "marketDomain")
let backgroundColor = UIColor(hexString: primaryColor) ?? AppConstants.defaultBrandColor
let eventHeaderTypeString = Config.shared.get(for: "eventHeaderType")
let eventHeaderType = EventHeaderType(rawValue: eventHeaderTypeString)
let marketDomain = MarketDomainObject.shared.getMarketDomain()
let marketDomain = MarketDomainObject.shared.getMarketDomain(marketDomainConfig: marketDomainConfig)

TMPurchase.shared.configure(apiKey: apiKey, region: TMAuthentication.TMXDeploymentRegion(rawValue: region) ?? .US, completion: {isPurchaseApiSet in
print("Purchase api key set result: \(isPurchaseApiSet)")
Expand Down
3 changes: 2 additions & 1 deletion ios/PrePurchaseSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class PrePurchaseSDK: UIViewController {
let apiKey = Config.shared.get(for: "apiKey")
let region = Config.shared.get(for: "region")
let primaryColor = Config.shared.get(for: "primaryColor")
let marketDomainConfig = Config.shared.get(for: "marketDomain")
let backgroundColor = UIColor(hexString: primaryColor) ?? AppConstants.defaultBrandColor
let marketDomain = MarketDomainObject.shared.getMarketDomain()
let marketDomain = MarketDomainObject.shared.getMarketDomain(marketDomainConfig: marketDomainConfig)

TMPrePurchase.shared.configure(apiKey: apiKey, region: TMAuthentication.TMXDeploymentRegion(rawValue: region) ?? .US, completion: { isPrePurchaseApiSet in
print("PrePurchase api key set result: \(isPrePurchaseApiSet)")
Expand Down
3 changes: 2 additions & 1 deletion ios/PurchaseSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ class PurchaseSDK: UIViewController {
let apiKey = Config.shared.get(for: "apiKey")
let region = Config.shared.get(for: "region")
let primaryColor = Config.shared.get(for: "primaryColor")
let marketDomainConfig = Config.shared.get(for: "marketDomain")
let backgroundColor = UIColor(hexString: primaryColor) ?? AppConstants.defaultBrandColor
let eventHeaderTypeString = Config.shared.get(for: "eventHeaderType")
let eventHeaderType = EventHeaderType(rawValue: eventHeaderTypeString)
let marketDomain = MarketDomainObject.shared.getMarketDomain()
let marketDomain = MarketDomainObject.shared.getMarketDomain(marketDomainConfig: marketDomainConfig)

TMPurchase.shared.configure(apiKey: apiKey, region: TMAuthentication.TMXDeploymentRegion(rawValue: region) ?? .US, completion: { isPurchaseApiSet in
print("Purchase api key set result: \(isPurchaseApiSet)")
Expand Down
Loading