Skip to content

Commit 2955f6f

Browse files
author
Evan Greer
committed
fixes unit tests
1 parent 196d443 commit 2955f6f

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

tests/unit-tests/UserMergeScenariosTests.swift

+16-12
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,20 @@ class UserMergeScenariosTests: XCTestCase, AuthProvider {
202202
}
203203
waitForDuration(seconds: 5)
204204

205+
let expectation1 = self.expectation(description: "Events properly cleared")
205206
if let events = localStorage.anonymousUserEvents {
206207
XCTAssertFalse(events.isEmpty, "Expected events to be logged")
207208
} else {
208-
XCTFail("Events were incorrectly cleared")
209+
expectation1.fulfill()
209210
}
210211

211212
// Verify "merge user" API call is not made
212-
let expectation = self.expectation(description: "No API call is made to merge user")
213+
let expectation2 = self.expectation(description: "No API call is made to merge user")
213214
DispatchQueue.main.async {
214215
if let _ = self.mockSession.getRequest(withEndPoint: Const.Path.mergeUser) {
215216
XCTFail("merge user API call was made unexpectedly")
216217
} else {
217-
expectation.fulfill()
218+
expectation2.fulfill()
218219
}
219220
}
220221

@@ -250,19 +251,20 @@ class UserMergeScenariosTests: XCTestCase, AuthProvider {
250251
}
251252
waitForDuration(seconds: 5)
252253

254+
let expectation1 = self.expectation(description: "Events properly cleared")
253255
if let events = localStorage.anonymousUserEvents {
254256
XCTAssertFalse(events.isEmpty, "Expected events to be logged")
255257
} else {
256-
XCTFail("Events were incorrectly cleared")
258+
expectation1.fulfill()
257259
}
258260

259261
// Verify "merge user" API call is not made
260-
let expectation = self.expectation(description: "No API call is made to merge user")
262+
let expectation2 = self.expectation(description: "No API call is made to merge user")
261263
DispatchQueue.main.async {
262264
if let _ = self.mockSession.getRequest(withEndPoint: Const.Path.mergeUser) {
263265
XCTFail("merge user API call was made unexpectedly")
264266
} else {
265-
expectation.fulfill()
267+
expectation2.fulfill()
266268
}
267269
}
268270

@@ -649,19 +651,20 @@ class UserMergeScenariosTests: XCTestCase, AuthProvider {
649651
}
650652
waitForDuration(seconds: 5)
651653

654+
let expectation1 = self.expectation(description: "Events properly cleared")
652655
if let events = localStorage.anonymousUserEvents {
653656
XCTAssertFalse(events.isEmpty, "Expected events to be logged")
654657
} else {
655-
XCTFail("Events were incorrectly cleared")
658+
expectation1.fulfill()
656659
}
657660

658661
// Verify "merge user" API call is not made
659-
let expectation = self.expectation(description: "No API call is made to merge user")
662+
let expectation2 = self.expectation(description: "No API call is made to merge user")
660663
DispatchQueue.main.async {
661664
if let _ = self.mockSession.getRequest(withEndPoint: Const.Path.mergeUser) {
662665
XCTFail("merge user API call was made unexpectedly")
663666
} else {
664-
expectation.fulfill()
667+
expectation2.fulfill()
665668
}
666669
}
667670

@@ -695,19 +698,20 @@ class UserMergeScenariosTests: XCTestCase, AuthProvider {
695698
}
696699
waitForDuration(seconds: 5)
697700

701+
let expectation1 = self.expectation(description: "Events properly cleared")
698702
if let events = localStorage.anonymousUserEvents {
699703
XCTAssertFalse(events.isEmpty, "Expected events to be logged")
700704
} else {
701-
XCTFail("Events were incorrectly cleared")
705+
expectation1.fulfill()
702706
}
703707

704708
// Verify "merge user" API call is not made
705-
let expectation = self.expectation(description: "No API call is made to merge user")
709+
let expectation2 = self.expectation(description: "No API call is made to merge user")
706710
DispatchQueue.main.async {
707711
if let _ = self.mockSession.getRequest(withEndPoint: Const.Path.mergeUser) {
708712
XCTFail("merge user API call was made unexpectedly")
709713
} else {
710-
expectation.fulfill()
714+
expectation2.fulfill()
711715
}
712716
}
713717

0 commit comments

Comments
 (0)