Skip to content

Commit

Permalink
fix: prevent error when personaData has empty arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidsowardx committed Jun 11, 2024
1 parent ce2f00e commit 108bc77
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, it } from 'vitest'
import { transformWalletDataToConnectButton } from './wallet-data-to-connect-button'
describe('transformWalletDataToConnectButton', () => {
describe('when persona data contain empty arrays', () => {
it('should not fail', () => {
// Arrange
const walletData = {
personaData: [
{
entry: 'emailAddresses',
fields: [],
},
{
entry: 'phoneNumbers',
fields: [],
},
],
} as any

// Act
const result = transformWalletDataToConnectButton(walletData)

// Assert
expect(result).toEqual({
accounts: [],
personaLabel: '',
connected: false,
personaData: [],
})
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const transformWalletDataToConnectButton = (walletData: WalletData) => {
): item is {
value: string
field: string
} => !!item && !!item.value.trim(),
} => !!item && !!item.value?.trim(),
)

return { accounts, personaLabel, connected, personaData }
Expand Down

0 comments on commit 108bc77

Please sign in to comment.