Skip to content

Commit

Permalink
Added missing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stechiu committed Dec 17, 2024
1 parent 4c61f94 commit 590ad21
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/BraintreeShopperInsights/BTExperimentType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum BTExperimentType: String {
"""
[
{ "exp_name" : "PaymentReady" }
{ "treatment_name" : \(self.rawValue) }
{ "treatment_name" : "\(self.rawValue)" }
]
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public class BTShopperInsightsClient {
buttonOrder: presentmentDetails.buttonOrder.rawValue,
buttonType: buttonType.rawValue,
experimentType: presentmentDetails.experimentType.formattedExperiment,
pageType: presentmentDetails.pageType.rawValue
pageType: presentmentDetails.pageType.rawValue,
shopperSessionID: shopperSessionID
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,13 @@ class BTShopperInsightsClient_Tests: XCTestCase {
XCTAssertEqual(mockAPIClient.postedAnalyticsEvents.first, "shopper-insights:button-presented")
XCTAssertEqual(mockAPIClient.postedButtonOrder, 0)
XCTAssertEqual(mockAPIClient.postedButtonType, "PayPal")
XCTAssertEqual(mockAPIClient.postedExperimentType, "control")
XCTAssertEqual(mockAPIClient.postedExperimentType,
"""
[
{ "exp_name" : "PaymentReady" }
{ "treatment_name" : "control" }
]
""")
XCTAssertEqual(mockAPIClient.postedPageType, "about")
}

Expand All @@ -236,7 +242,13 @@ class BTShopperInsightsClient_Tests: XCTestCase {
XCTAssertEqual(mockAPIClient.postedAnalyticsEvents.first, "shopper-insights:button-presented")
XCTAssertEqual(mockAPIClient.postedButtonOrder, 0)
XCTAssertEqual(mockAPIClient.postedButtonType, "Venmo")
XCTAssertEqual(mockAPIClient.postedExperimentType, "control")
XCTAssertEqual(mockAPIClient.postedExperimentType,
"""
[
{ "exp_name" : "PaymentReady" }
{ "treatment_name" : "control" }
]
""")
XCTAssertEqual(mockAPIClient.postedPageType, "about")
}

Expand Down
4 changes: 4 additions & 0 deletions UnitTests/BraintreeTestShared/MockAPIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public class MockAPIClient: BTAPIClient {
payPalContextID: String? = nil,
shopperSessionID: String? = nil
) {
postedButtonType = buttonType
postedButtonOrder = buttonOrder
postedExperimentType = experimentType
postedPageType = pageType
postedPayPalContextID = payPalContextID
postedLinkType = linkType
postedIsVaultRequest = isVaultRequest ?? false
Expand Down

0 comments on commit 590ad21

Please sign in to comment.