From 590ad215829b13810c9df7ed7a0d0e5f6ba3a237 Mon Sep 17 00:00:00 2001 From: stechiu Date: Tue, 17 Dec 2024 12:36:46 -0800 Subject: [PATCH] Added missing unit tests --- .../BTExperimentType.swift | 2 +- .../BTShopperInsightsClient.swift | 3 ++- .../BTShopperInsightsClient_Tests.swift | 16 ++++++++++++++-- .../BraintreeTestShared/MockAPIClient.swift | 4 ++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Sources/BraintreeShopperInsights/BTExperimentType.swift b/Sources/BraintreeShopperInsights/BTExperimentType.swift index 53ae86828..60cf4e2e9 100644 --- a/Sources/BraintreeShopperInsights/BTExperimentType.swift +++ b/Sources/BraintreeShopperInsights/BTExperimentType.swift @@ -14,7 +14,7 @@ public enum BTExperimentType: String { """ [ { "exp_name" : "PaymentReady" } - { "treatment_name" : \(self.rawValue) } + { "treatment_name" : "\(self.rawValue)" } ] """ } diff --git a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift index b2debe98d..3e883ccd5 100644 --- a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift +++ b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift @@ -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 ) } diff --git a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift index 61e7fd94c..58d5effe3 100644 --- a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift +++ b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift @@ -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") } @@ -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") } diff --git a/UnitTests/BraintreeTestShared/MockAPIClient.swift b/UnitTests/BraintreeTestShared/MockAPIClient.swift index 97a43aa7b..aa1ee24be 100644 --- a/UnitTests/BraintreeTestShared/MockAPIClient.swift +++ b/UnitTests/BraintreeTestShared/MockAPIClient.swift @@ -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