Skip to content

Commit 38fc83a

Browse files
committed
test: add btc account tests
1 parent d853bf1 commit 38fc83a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

ui/pages/multichain-accounts/account-details/account-type-utils.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { InternalAccount } from '@metamask/keyring-internal-api';
22
import {
3+
MOCK_ACCOUNT_BIP122_P2WPKH,
34
MOCK_ACCOUNT_EOA,
45
MOCK_ACCOUNT_ERC4337,
56
MOCK_ACCOUNT_HARDWARE,
@@ -14,6 +15,7 @@ import {
1415
isHardwareAccount,
1516
isPrivateKeyAccount,
1617
isInstitutionalEVMAccount,
18+
isBitcoinAccount,
1719
} from './account-type-utils';
1820

1921
describe('Account Type Utils', () => {
@@ -111,4 +113,18 @@ describe('Account Type Utils', () => {
111113
expect(isInstitutionalEVMAccount(MOCK_ACCOUNT_ERC4337)).toBe(false);
112114
});
113115
});
116+
117+
describe('isBitcoinAccount', () => {
118+
it('should return true for Bitcoin accounts', () => {
119+
expect(isBitcoinAccount(MOCK_ACCOUNT_BIP122_P2WPKH)).toBe(true);
120+
});
121+
122+
it('should return false for EOA accounts', () => {
123+
expect(isBitcoinAccount(MOCK_ACCOUNT_EOA)).toBe(false);
124+
});
125+
126+
it('should return false for Solana accounts', () => {
127+
expect(isBitcoinAccount(MOCK_ACCOUNT_SOLANA_MAINNET)).toBe(false);
128+
});
129+
});
114130
});

ui/pages/multichain-accounts/account-details/account-type-utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,12 @@ export const isInstitutionalEVMAccount = (
118118
): boolean => {
119119
return getAccountTypeCategory(account) === 'institutional-evm';
120120
};
121+
122+
/**
123+
* Checks if an account is a Bitcoin account
124+
*
125+
* @param account - The internal account object to check.
126+
*/
127+
export const isBitcoinAccount = (account: InternalAccount): boolean => {
128+
return getAccountTypeCategory(account) === 'bitcoin';
129+
};

0 commit comments

Comments
 (0)