-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
Tests/UnleashProxyClientSwiftTests/UnleashClientIntegrationTest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import XCTest | ||
@testable import UnleashProxyClientSwift | ||
|
||
class UnleashIntegrationTests: XCTestCase { | ||
|
||
var unleashClient: UnleashProxyClientSwift.UnleashClientBase! | ||
let featureName = "enabled-feature" | ||
|
||
override func setUpWithError() throws { | ||
unleashClient = UnleashProxyClientSwift.UnleashClientBase( | ||
unleashUrl: "https://sandbox.getunleash.io/enterprise/api/frontend", | ||
clientKey: "SDKIntegration:development.f0474f4a37e60794ee8fb00a4c112de58befde962af6d5055b383ea3", | ||
refreshInterval: 15, | ||
appName: "testIntegration" | ||
) | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
unleashClient.stop() | ||
} | ||
|
||
func testEnabledFeatureWithVariant() { | ||
let expectation = self.expectation(description: "Waiting for client ready") | ||
|
||
unleashClient.subscribe(name: "ready", callback: { | ||
XCTAssertTrue(self.unleashClient.isEnabled(name: self.featureName), "Feature should be enabled") | ||
|
||
let variant = self.unleashClient.getVariant(name: self.featureName) | ||
XCTAssertNotNil(variant, "Variant should not be nil") | ||
XCTAssertTrue(variant.enabled, "Variant should be enabled") | ||
|
||
expectation.fulfill() | ||
}) | ||
|
||
unleashClient.start() | ||
|
||
wait(for: [expectation], timeout: 40) | ||
} | ||
|
||
} |