Skip to content

Commit

Permalink
fix: right a test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Apr 24, 2024
1 parent dbcce93 commit bf90e80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 5 additions & 9 deletions example/src/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,12 @@ function GroupListItem({
DecodedMessage<SupportedContentTypes>[]
>([])
const lastMessage = messages?.[0]
const [getConsentState, setConsentState] = useState<string | undefined>()
const [consentState, setConsentState] = useState<string | undefined>()

const denyGroup = async () => {
await client?.contacts.denyGroups([group.id])
group
.consentState()
.then(setConsentState)
.catch((e) => {
console.error('Error denying contact: ', e)
})
const consent = await group.consentState()
setConsentState(consent)
}

useEffect(() => {
Expand Down Expand Up @@ -147,12 +143,12 @@ function GroupListItem({
<Button
title="Deny"
onPress={denyGroup}
disabled={getConsentState === 'denied'}
disabled={consentState === 'denied'}
/>
</View>
<View style={{ padding: 4 }}>
<Text style={{ fontWeight: 'bold', color: 'red' }}>
{getConsentState}
{consentState}
</Text>
<Text numberOfLines={1} ellipsizeMode="tail">
{lastMessage?.fallback}
Expand Down
6 changes: 6 additions & 0 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,12 @@ test('creating a group should allow group', async () => {
throw Error('Group should be allowed')
}

const state = await group.consentState()
assert(
state === 'allowed',
`the message should have a consent state of allowed but was ${state}`
)

return true
})

Expand Down

0 comments on commit bf90e80

Please sign in to comment.