diff --git a/Sources/DataPipeline/Type/Aliases.swift b/Sources/DataPipeline/Type/Aliases.swift index ab69988fd..410aba948 100644 --- a/Sources/DataPipeline/Type/Aliases.swift +++ b/Sources/DataPipeline/Type/Aliases.swift @@ -31,3 +31,4 @@ public typealias OperatingMode = Segment.OperatingMode public typealias Metric = CioInternalCommon.Metric public typealias CustomerIO = CioInternalCommon.CustomerIO public typealias CioLogLevel = CioInternalCommon.CioLogLevel +public typealias Region = CioInternalCommon.Region diff --git a/Tests/Common/APITest.swift b/Tests/Common/APITest.swift index defdab764..428434eb7 100644 --- a/Tests/Common/APITest.swift +++ b/Tests/Common/APITest.swift @@ -13,6 +13,12 @@ import XCTest class CommonAPITest: UnitTest { // Test that public functions are accessible by mocked instances let mock = CustomerIOInstanceMock() + let dictionaryData: [String: Any] = ["foo": true, "bar": ""] + struct CodableExample: Codable { + let foo: String + } + + let codedData = CodableExample(foo: "") func test_allPublicStaticPropertiesAvailable() throws { try skipRunningTest() @@ -28,6 +34,39 @@ class CommonAPITest: UnitTest { // Reference some objects that should be public in the Tracking module let _: Region = .EU let _: CioLogLevel = .debug + + mock.identify(userId: "", traits: nil) + mock.identify(userId: "", traits: dictionaryData) + mock.identify(userId: "", traits: codedData) + + // clear identify + mock.clearIdentify() + + // event tracking + mock.track(name: "", properties: nil) + mock.track(name: "", properties: dictionaryData) + mock.track(name: "", properties: codedData) + + // screen tracking + mock.screen(title: "", properties: nil) + mock.screen(title: "", properties: dictionaryData) + mock.screen(title: "", properties: codedData) + + // register push token + mock.registerDeviceToken("") + + // delete push token + mock.deleteDeviceToken() + + // track push metric + let metric = Metric.delivered + mock.trackMetric(deliveryID: "", event: metric, deviceToken: "") + + // profile attributes + mock.profileAttributes = dictionaryData + + // device attributes + mock.deviceAttributes = dictionaryData } // This function checks that SdkConfig is accessible and can be created using the factory. diff --git a/Tests/DataPipeline/APITest.swift b/Tests/DataPipeline/APITest.swift index 9ff727e2c..c20830ef5 100644 --- a/Tests/DataPipeline/APITest.swift +++ b/Tests/DataPipeline/APITest.swift @@ -1,5 +1,4 @@ import CioDataPipelines // do not use `@testable` so we can test functions are made public and not `internal`. -import CioInternalCommon import Foundation import Segment import SharedTests @@ -21,9 +20,6 @@ class DataPipelineAPITest: UnitTest { let codedData = CodableExample(foo: "") let exampleURL = URL(string: "https://example.com")! - // Test that public functions are accessible by mocked instances - let mock = CustomerIOInstanceMock() - // This function checks that public functions exist for the SDK and they are callable. // Maybe we forgot to add a function? Maybe we forgot to make a function `public`? func test_allPublicFunctions() throws { @@ -34,52 +30,37 @@ class DataPipelineAPITest: UnitTest { // Identify CustomerIO.shared.identify(userId: "") - mock.identify(userId: "", traits: nil) CustomerIO.shared.identify(userId: "", traits: dictionaryData) - mock.identify(userId: "", traits: dictionaryData) CustomerIO.shared.identify(userId: "", traits: codedData) - mock.identify(userId: "", traits: codedData) // clear identify CustomerIO.shared.clearIdentify() - mock.clearIdentify() // event tracking CustomerIO.shared.track(name: "") - mock.track(name: "", properties: nil) CustomerIO.shared.track(name: "", properties: dictionaryData) - mock.track(name: "", properties: dictionaryData) CustomerIO.shared.track(name: "", properties: codedData) - mock.track(name: "", properties: codedData) // screen tracking CustomerIO.shared.screen(title: "") - mock.screen(title: "", properties: nil) CustomerIO.shared.screen(title: "", properties: dictionaryData) - mock.screen(title: "", properties: dictionaryData) CustomerIO.shared.screen(title: "", properties: codedData) - mock.screen(title: "", properties: codedData) // register push token CustomerIO.shared.registerDeviceToken("") - mock.registerDeviceToken("") // delete push token CustomerIO.shared.deleteDeviceToken() - mock.deleteDeviceToken() // track push metric let metric = Metric.delivered CustomerIO.shared.trackMetric(deliveryID: "", event: metric, deviceToken: "") - mock.trackMetric(deliveryID: "", event: metric, deviceToken: "") // profile attributes CustomerIO.shared.profileAttributes = dictionaryData - mock.profileAttributes = dictionaryData // device attributes CustomerIO.shared.deviceAttributes = dictionaryData - mock.deviceAttributes = dictionaryData // plugins CustomerIO.shared.apply { (_: Plugin) in } @@ -110,6 +91,7 @@ class DataPipelineAPITest: UnitTest { try skipRunningTest() _ = SDKConfigBuilder(cdpApiKey: .random) + .region(.US) .logLevel(.info) .apiHost("") .cdnHost("")