Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit 55a0283

Browse files
committed
fix: tests and docs
1 parent e8b2f23 commit 55a0283

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

.vscode/launch.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,49 @@
66
"request": "launch",
77
"name": "🍎 Open Example in Xcode",
88
"command": "open Martie.xcodeproj",
9-
"cwd": "${workspaceFolder}/Example",
10-
"group": "build"
9+
"cwd": "${workspaceFolder}/Example"
1110
},
1211
{
1312
"type": "node-terminal",
1413
"request": "launch",
1514
"name": "📱 Build & Run Example (iOS Simulator)",
1615
"command": "xcodebuild -project Martie.xcodeproj -scheme OpenIapExample -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.5' build",
17-
"cwd": "${workspaceFolder}/Example",
18-
"group": "build"
16+
"cwd": "${workspaceFolder}/Example"
1917
},
2018
{
2119
"type": "node-terminal",
2220
"request": "launch",
2321
"name": "📦 Swift Package Build",
2422
"command": "swift build",
25-
"cwd": "${workspaceFolder}",
26-
"group": "build"
23+
"cwd": "${workspaceFolder}"
2724
},
2825
{
2926
"type": "node-terminal",
3027
"request": "launch",
3128
"name": "🧪 Swift Package Test",
3229
"command": "swift test",
33-
"cwd": "${workspaceFolder}",
34-
"group": "test"
30+
"cwd": "${workspaceFolder}"
3531
},
3632
{
3733
"type": "node-terminal",
3834
"request": "launch",
3935
"name": "☕ CocoaPods Build",
4036
"command": "pod install",
41-
"cwd": "${workspaceFolder}",
42-
"group": "build"
37+
"cwd": "${workspaceFolder}"
4338
},
4439
{
4540
"type": "node-terminal",
4641
"request": "launch",
4742
"name": "🔍 CocoaPods Lint",
4843
"command": "pod lib lint --allow-warnings",
49-
"cwd": "${workspaceFolder}",
50-
"group": "build"
44+
"cwd": "${workspaceFolder}"
45+
},
46+
{
47+
"type": "node-terminal",
48+
"request": "launch",
49+
"name": "🚀 Swift Test (Watch Mode)",
50+
"command": "swift test --parallel",
51+
"cwd": "${workspaceFolder}"
5152
}
5253
]
5354
}

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ let productIds = ["dev.hyo.premium", "dev.hyo.coins"]
8989
let products = try await OpenIapModule.shared.fetchProducts(skus: productIds)
9090

9191
for product in products {
92-
print("\(product.title): \(product.displayPrice)")
92+
print("\(product.localizedTitle): \(product.localizedPrice)")
9393
}
9494
```
9595

@@ -159,16 +159,20 @@ swift test
159159

160160
## 📚 Data Models
161161

162-
### OpenIapProductData
162+
### OpenIapProduct
163163

164164
```swift
165-
struct OpenIapProductData {
165+
struct OpenIapProduct {
166166
let id: String
167-
let title: String
168-
let description: String
167+
let productType: ProductType
168+
let localizedTitle: String
169+
let localizedDescription: String
169170
let price: Decimal
170-
let displayPrice: String
171-
let type: String
171+
let localizedPrice: String
172+
let currencyCode: String?
173+
let countryCode: String?
174+
let subscriptionPeriod: SubscriptionPeriod?
175+
let introductoryPrice: IntroductoryOffer?
172176
let platform: String
173177
}
174178
```
@@ -177,15 +181,19 @@ struct OpenIapProductData {
177181

178182
```swift
179183
struct OpenIapPurchase {
184+
let id: String // Transaction ID
180185
let productId: String
181186
let transactionId: String
182187
let purchaseTime: Date
183188
let purchaseState: PurchaseState
189+
let acknowledgementState: AcknowledgementState
184190
let isAutoRenewing: Bool
191+
let quantity: Int
185192

186193
// iOS-specific StoreKit 2 properties
187194
let environmentIOS: String?
188195
let storefrontCountryCodeIOS: String?
196+
let jwsRepresentation: String?
189197
// ... additional properties
190198
}
191199
```

Tests/OpenIapTests.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ final class OpenIapTests: XCTestCase {
4545

4646
func testPurchaseModel() {
4747
let purchase = OpenIapPurchase(
48-
id: "dev.hyo.premium",
48+
id: "trans123",
49+
productId: "dev.hyo.premium",
4950
purchaseToken: "token123",
5051
transactionId: "trans123",
5152
originalTransactionId: "original123",
@@ -81,7 +82,7 @@ final class OpenIapTests: XCTestCase {
8182
countryCodeIOS: "US"
8283
)
8384

84-
XCTAssertEqual(purchase.id, "dev.hyo.premium")
85+
XCTAssertEqual(purchase.id, "trans123")
8586
XCTAssertEqual(purchase.purchaseState, .purchased)
8687
XCTAssertEqual(purchase.acknowledgementState, .acknowledged)
8788
XCTAssertTrue(purchase.isAutoRenewing)
@@ -129,7 +130,8 @@ final class OpenIapTests: XCTestCase {
129130
func testReceipt() {
130131
let purchases = [
131132
OpenIapPurchase(
132-
id: "product1",
133+
id: "trans1",
134+
productId: "product1",
133135
purchaseToken: "token1",
134136
transactionId: "trans1",
135137
originalTransactionId: nil,
@@ -178,6 +180,6 @@ final class OpenIapTests: XCTestCase {
178180
XCTAssertEqual(receipt.bundleId, "dev.hyo.app")
179181
XCTAssertEqual(receipt.applicationVersion, "1.0.0")
180182
XCTAssertEqual(receipt.inAppPurchases.count, 1)
181-
XCTAssertEqual(receipt.inAppPurchases.first?.id, "product1")
183+
XCTAssertEqual(receipt.inAppPurchases.first?.id, "trans1")
182184
}
183185
}

0 commit comments

Comments
 (0)