Skip to content

Commit

Permalink
add tests for the streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Feb 16, 2024
1 parent 85dc6b4 commit 1eac68b
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Tests/XMTPTests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,53 @@ class GroupTests: XCTestCase {
XCTAssertEqual("sup gang", String(data: Data(aliceMessage.encodedContent.content), encoding: .utf8))
XCTAssertEqual("sup gang", String(data: Data(bobMessage.encodedContent.content), encoding: .utf8))
}

func testCanStreamGroups() async throws {
let fixtures = try await localFixtures()

let expectation1 = expectation(description: "got a group")

Task(priority: .userInitiated) {
for try await _ in try await fixtures.aliceClient.conversations.streamGroups() {
expectation1.fulfill()
}
}

try await fixtures.bobClient.conversations.newGroup(with: [fixtures.alice.address])

await waitForExpectations(timeout: 3)
}

func testCanStreamGroupsAndConversationsWorksGroups() async throws {
let fixtures = try await localFixtures()

let expectation1 = expectation(description: "got a conversation")

Task(priority: .userInitiated) {
for try await _ in try await fixtures.aliceClient.conversations.streamAll() {
expectation1.fulfill()
}
}

_ = try await fixtures.bobClient.conversations.newGroup(with: [fixtures.alice.address])
// _ = try await fixtures.bobClient.conversations.newConversation(with: fixtures.alice.address)

await waitForExpectations(timeout: 3)
}

func testCanStreamGroupsAndConversationsWorksConvos() async throws {
let fixtures = try await localFixtures()

let expectation1 = expectation(description: "got a conversation")

Task(priority: .userInitiated) {
for try await _ in try await fixtures.aliceClient.conversations.streamAll() {
expectation1.fulfill()
}
}

_ = try await fixtures.bobClient.conversations.newConversation(with: fixtures.alice.address)

await waitForExpectations(timeout: 3)
}
}

0 comments on commit 1eac68b

Please sign in to comment.