Skip to content

Commit 3136b45

Browse files
committed
tests
1 parent a7cc3e3 commit 3136b45

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Sources/FormbricksSDK/Formbricks.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import Network
3939
Formbricks.setup(with: config)
4040
```
4141
*/
42-
@objc public static func setup(with config: FormbricksConfig, force: Bool = false) {
42+
@objc public static func setup(with config: FormbricksConfig, force: Bool = false, skipInitiFetch: Bool = false) {
4343
logger = Logger()
4444
apiQueue = OperationQueue()
4545

@@ -73,8 +73,10 @@ import Network
7373
surveyManager = SurveyManager.create(userManager: userManager!, presentSurveyManager: presentSurveyManager!)
7474
userManager?.surveyManager = surveyManager
7575

76-
surveyManager?.refreshEnvironmentIfNeeded(force: force)
77-
userManager?.syncUserStateIfNeeded()
76+
if !skipInitiFetch {
77+
surveyManager?.refreshEnvironmentIfNeeded(force: force)
78+
userManager?.syncUserStateIfNeeded()
79+
}
7880

7981
self.isInitialized = true
8082
}

Tests/FormbricksSDKTests/FormbricksSDKTests.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,21 @@ final class FormbricksSDKTests: XCTestCase {
4444
Formbricks.setAttribute("test", forKey: "testKey")
4545
XCTAssertNil(Formbricks.userManager?.userId)
4646

47-
Formbricks.apiQueue?.isSuspended = true
48-
4947
// Setup the SDK using your new instance-based design.
5048
// This creates new instances for both the UserManager and SurveyManager.
5149
Formbricks.setup(with: FormbricksConfig.Builder(appUrl: appUrl, environmentId: environmentId)
5250
.set(attributes: ["a": "b"])
5351
.add(attribute: "test", forKey: "key")
5452
.setLogLevel(.debug)
55-
.build())
53+
.build(),
54+
force: true,
55+
skipInitiFetch: true
56+
)
5657

5758
// IMPORTANT: Set up the service dependency on both managers BEFORE any API calls happen
5859
Formbricks.userManager?.service = mockService
5960
Formbricks.surveyManager?.service = mockService
6061

61-
Formbricks.apiQueue?.isSuspended = false
62-
6362
XCTAssertTrue(Formbricks.isInitialized)
6463
XCTAssertEqual(Formbricks.appUrl, appUrl)
6564
XCTAssertEqual(Formbricks.environmentId, environmentId)

0 commit comments

Comments
 (0)