Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Dec 13, 2024
1 parent 2b0c30c commit 258fa17
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions bindings_node/test/Conversations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
Conversation,
GroupPermissionsOptions,
Message,
MetadataField,
PermissionPolicy,
PermissionUpdateType,
} from '../dist'

const SLEEP_MS = 100
Expand Down Expand Up @@ -116,6 +119,60 @@ describe('Conversations', () => {
})
})

it('should update group permission policy', async () => {
const user1 = createUser()
const user2 = createUser()
const client1 = await createRegisteredClient(user1)
const client2 = await createRegisteredClient(user2)
const group = await client1
.conversations()
.createGroup([user2.account.address])

expect(group.groupPermissions().policySet()).toEqual({
addMemberPolicy: 0,
removeMemberPolicy: 2,
addAdminPolicy: 3,
removeAdminPolicy: 3,
updateGroupNamePolicy: 0,
updateGroupDescriptionPolicy: 0,
updateGroupImageUrlSquarePolicy: 0,
updateGroupPinnedFrameUrlPolicy: 0,
})

await group.updatePermissionPolicy(
PermissionUpdateType.AddAdmin,
PermissionPolicy.Deny
)

expect(group.groupPermissions().policySet()).toEqual({
addMemberPolicy: 0,
removeMemberPolicy: 2,
addAdminPolicy: 1,
removeAdminPolicy: 3,
updateGroupNamePolicy: 0,
updateGroupDescriptionPolicy: 0,
updateGroupImageUrlSquarePolicy: 0,
updateGroupPinnedFrameUrlPolicy: 0,
})

await group.updatePermissionPolicy(
PermissionUpdateType.UpdateMetadata,
PermissionPolicy.Deny,
MetadataField.GroupName
)

expect(group.groupPermissions().policySet()).toEqual({
addMemberPolicy: 0,
removeMemberPolicy: 2,
addAdminPolicy: 1,
removeAdminPolicy: 3,
updateGroupNamePolicy: 1,
updateGroupDescriptionPolicy: 0,
updateGroupImageUrlSquarePolicy: 0,
updateGroupPinnedFrameUrlPolicy: 0,
})
})

it('should create a dm group', async () => {
const user1 = createUser()
const user2 = createUser()
Expand Down

0 comments on commit 258fa17

Please sign in to comment.