Skip to content

Commit

Permalink
test: add test for configured user provider
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori committed Aug 10, 2021
1 parent 1e4a05c commit 401a0f3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Tests/ExperimentTests/ExperimentClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,32 @@ class ExperimentClientTests: XCTestCase {
XCTAssertEqual(expectedUserAfterMerge, mergedUser)
}

func testMergeUserWithConfiguredProvider() {
let client = DefaultExperimentClient(
apiKey: API_KEY,
config: ExperimentConfig.Builder()
.userProvider(TestUserProvider())
.build(),
storage: InMemoryStorage()
)
let user = ExperimentUser.Builder()
.deviceId("device_id")
.userId(nil)
.version("version")
.build()
client.setUser(user)
let mergedUser = client.mergeUserWithProvider()
let expectedUserAfterMerge = ExperimentUser.Builder()
.deviceId("device_id")
.userId(nil)
.version("version")
.language("")
.library("\(ExperimentConfig.Constants.Library)/\(ExperimentConfig.Constants.Version)")
.build()
XCTAssertEqual(expectedUserAfterMerge, mergedUser)
}


func testInitialVariantsSourceOverridesFetch() {
var variant = initialVariantSourceClient.variant(KEY, fallback: nil)
XCTAssertNotNil(variant)
Expand Down

0 comments on commit 401a0f3

Please sign in to comment.