Skip to content

Commit

Permalink
add test for is active
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Feb 13, 2024
1 parent 958979d commit 22df075
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
.package(url: "https://github.com/1024jp/GzipSwift", from: "5.2.0"),
.package(url: "https://github.com/bufbuild/connect-swift", exact: "0.3.0"),
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"),
.package(url: "https://github.com/xmtp/libxmtp-swift", exact: "0.4.1-beta2"),
.package(url: "https://github.com/xmtp/libxmtp-swift", exact: "0.4.1-beta3"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
39 changes: 39 additions & 0 deletions Tests/XMTPTests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,45 @@ class GroupTests: XCTestCase {
let groupChangedMessage: GroupMembershipChanges = try await group.messages().last!.content()
XCTAssertEqual(groupChangedMessage.membersRemoved.map(\.accountAddress.localizedLowercase), [fixtures.fred.address.localizedLowercase])
}

func testIsActive() async throws {
let fixtures = try await localFixtures()
let group = try await fixtures.aliceClient.conversations.newGroup(with: [fixtures.bob.address, fixtures.fred.address])

try await group.sync()
let members = group.memberAddresses.map(\.localizedLowercase).sorted()

XCTAssertEqual([
fixtures.bob.address.localizedLowercase,
fixtures.alice.address.localizedLowercase,
fixtures.fred.address.localizedLowercase
].sorted(), members)

let fredGroup = try await fixtures.fredClient.conversations.groups().first

var isAliceActive = try await group.isActive()
var isFredActive = try await fredGroup!.isActive()

XCTAssert(isAliceActive)
XCTAssert(isFredActive)

try await group.removeMembers(addresses: [fixtures.fred.address])

try await group.sync()

let newMembers = group.memberAddresses.map(\.localizedLowercase).sorted()
XCTAssertEqual([
fixtures.bob.address.localizedLowercase,
fixtures.alice.address.localizedLowercase,
].sorted(), newMembers)

isAliceActive = try await group.isActive()
isFredActive = try await fredGroup!.isActive()

XCTAssert(isAliceActive)
XCTAssert(!isFredActive)
}


func testCannotStartGroupWithSelf() async throws {
let fixtures = try await localFixtures()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/xmtp/libxmtp-swift",
"state" : {
"revision" : "82398e41e54b52c346852a478102c7f620fd17a4",
"version" : "0.4.1-beta2"
"revision" : "d2d0312dd504f5c866e64d6c66c44729be43279c",
"version" : "0.4.1-beta3"
}
},
{
Expand Down

0 comments on commit 22df075

Please sign in to comment.