Skip to content

Commit

Permalink
test: integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Oct 25, 2023
1 parent 8360e37 commit acb872d
Showing 1 changed file with 40 additions and 0 deletions.
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)
}

}

0 comments on commit acb872d

Please sign in to comment.