Skip to content

Commit

Permalink
Fix: UnitTests
Browse files Browse the repository at this point in the history
  • Loading branch information
nimau committed Apr 27, 2023
1 parent 45ca433 commit fb064c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion MatrixSDKTests/MXCryptoSecretShareTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ - (void)testSecretShare
// -> She gets the secret
XCTAssertEqualObjects(sharedSecret, secret);
[expectation fulfill];

return YES;
} failure:^(NSError * _Nonnull error) {
XCTFail(@"The operation should not fail - NSError: %@", error);
[expectation fulfill];
Expand Down
34 changes: 17 additions & 17 deletions MatrixSDKTests/MXPollAggregatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class MXPollAggregatorTest: XCTestCase {
func testAggregations() {
self.createScenarioForBobAndAlice { bobSession, aliceSession, bobRoom, aliceRoom, pollStartEvent, expectation in
self.delegate = PollAggregatorBlockWrapper(dataUpdateCallback: { pollAggregator in
XCTAssertEqual(self.pollAggregator.poll.answerOptions.first!.count, 2)
XCTAssertEqual(self.pollAggregator.poll.answerOptions.last!.count, 0)
XCTAssertEqual(self.pollAggregator.poll?.answerOptions.first!.count, 2)
XCTAssertEqual(self.pollAggregator.poll?.answerOptions.last!.count, 0)
expectation.fulfill()
})

self.pollAggregator = try! PollAggregator(session: bobSession, room: bobRoom, pollStartEventId: pollStartEvent.eventId)
self.pollAggregator = PollAggregator(session: bobSession, room: bobRoom, pollStartEventId: pollStartEvent.eventId)

let dispatchGroup = DispatchGroup()

Expand Down Expand Up @@ -74,14 +74,14 @@ class MXPollAggregatorTest: XCTestCase {
func testSessionPausing() {
self.createScenarioForBobAndAlice { bobSession, aliceSession, bobRoom, aliceRoom, pollStartEvent, expectation in
let delegate = PollAggregatorBlockWrapper(dataUpdateCallback: { aggregator in
XCTAssertEqual(aggregator.poll.answerOptions.first!.count, 2)
XCTAssertEqual(aggregator.poll.answerOptions.last!.count, 0)
XCTAssertEqual(aggregator.poll?.answerOptions.first!.count, 2)
XCTAssertEqual(aggregator.poll?.answerOptions.last!.count, 0)
})

self.pollAggregator = try! PollAggregator(session: bobSession, room: bobRoom, pollStartEventId: pollStartEvent.eventId)
self.pollAggregator = PollAggregator(session: bobSession, room: bobRoom, pollStartEventId: pollStartEvent.eventId)

XCTAssertEqual(self.pollAggregator.poll.answerOptions.first!.count, 1) // One from Alice
XCTAssertEqual(self.pollAggregator.poll.answerOptions.last!.count, 0)
XCTAssertEqual(self.pollAggregator.poll?.answerOptions.first!.count, 1) // One from Alice
XCTAssertEqual(self.pollAggregator.poll?.answerOptions.last!.count, 0)

bobSession.pause()

Expand All @@ -99,16 +99,16 @@ class MXPollAggregatorTest: XCTestCase {

func testGappySync() {
self.createScenarioForBobAndAlice { bobSession, aliceSession, bobRoom, aliceRoom, pollStartEvent, expectation in
self.pollAggregator = try! PollAggregator(session: bobSession, room: bobRoom, pollStartEventId: pollStartEvent.eventId)
self.pollAggregator = PollAggregator(session: bobSession, room: bobRoom, pollStartEventId: pollStartEvent.eventId)

self.delegate = PollAggregatorBlockWrapper(dataUpdateCallback: { aggregator in
XCTAssertEqual(aggregator.poll.answerOptions.first!.count, 2) // One from Bob and one from Alice
XCTAssertEqual(aggregator.poll.answerOptions.last!.count, 1) // One from Alice
XCTAssertEqual(aggregator.poll?.answerOptions.first!.count, 2) // One from Bob and one from Alice
XCTAssertEqual(aggregator.poll?.answerOptions.last!.count, 1) // One from Alice
expectation.fulfill()
})

XCTAssertEqual(self.pollAggregator.poll.answerOptions.first!.count, 1) // One from Alice
XCTAssertEqual(self.pollAggregator.poll.answerOptions.last!.count, 0)
XCTAssertEqual(self.pollAggregator.poll?.answerOptions.first!.count, 1) // One from Alice
XCTAssertEqual(self.pollAggregator.poll?.answerOptions.last!.count, 0)

bobSession.pause()

Expand All @@ -135,7 +135,7 @@ class MXPollAggregatorTest: XCTestCase {

func testEditing() {
self.createScenarioForBobAndAlice { bobSession, aliceSession, bobRoom, aliceRoom, pollStartEvent, expectation in
self.pollAggregator = try! PollAggregator(session: bobSession, room: bobRoom, pollStartEventId: pollStartEvent.eventId)
self.pollAggregator = PollAggregator(session: bobSession, room: bobRoom, pollStartEventId: pollStartEvent.eventId)

self.delegate = PollAggregatorBlockWrapper(dataUpdateCallback: { aggregator in
defer {
Expand All @@ -144,9 +144,9 @@ class MXPollAggregatorTest: XCTestCase {
guard self.isFirstDelegateUpdate else {
return
}
XCTAssertEqual(aggregator.poll.text, "Some other question")
XCTAssertEqual(aggregator.poll.answerOptions.count, 2)
XCTAssertTrue(aggregator.poll.hasBeenEdited)
XCTAssertEqual(aggregator.poll?.text, "Some other question")
XCTAssertEqual(aggregator.poll?.answerOptions.count, 2)
XCTAssertEqual(aggregator.poll?.hasBeenEdited, true)
expectation.fulfill()
})

Expand Down

0 comments on commit fb064c4

Please sign in to comment.