diff --git a/packages/dapp-toolkit/src/modules/wallet-request/data-request/transformations/wallet-data-to-connect-button.spec.ts b/packages/dapp-toolkit/src/modules/wallet-request/data-request/transformations/wallet-data-to-connect-button.spec.ts new file mode 100644 index 00000000..d1b07fc3 --- /dev/null +++ b/packages/dapp-toolkit/src/modules/wallet-request/data-request/transformations/wallet-data-to-connect-button.spec.ts @@ -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: [], + }) + }) + }) +}) diff --git a/packages/dapp-toolkit/src/modules/wallet-request/data-request/transformations/wallet-data-to-connect-button.ts b/packages/dapp-toolkit/src/modules/wallet-request/data-request/transformations/wallet-data-to-connect-button.ts index 63841fd3..17b91f85 100644 --- a/packages/dapp-toolkit/src/modules/wallet-request/data-request/transformations/wallet-data-to-connect-button.ts +++ b/packages/dapp-toolkit/src/modules/wallet-request/data-request/transformations/wallet-data-to-connect-button.ts @@ -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 }