Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeRx committed Oct 16, 2024
1 parent 5f14a58 commit 240d3df
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
2 changes: 0 additions & 2 deletions ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1589,8 +1589,6 @@ export const getMemoizedUnapprovedTypedMessages = createDeepEqualSelector(
(unapprovedTypedMessages) => unapprovedTypedMessages,
);

export const selectAddress = (_, address) => address;

/**
* Get the display name for an address.
* This selector will look into the internal accounts and address book to find a display name for the address.
Expand Down
51 changes: 51 additions & 0 deletions ui/selectors/selectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,57 @@ describe('#getConnectedSitesList', () => {
});
});

describe('getAddressBookByNetwork', () => {
it('returns the address book for the given network', () => {
expect(selectors.getAddressBookByNetwork(mockState, '0x5')).toStrictEqual(
[
{
address: '0xc42edfcc21ed14dda456aa0756c153f7985d8813',
chainId: '0x5',
isEns: false,
memo: '',
name: 'Address Book Account 1',
},
],
);
});

it('returns an empty object if no address book is found for the given network', () => {
expect(selectors.getAddressBookByNetwork(mockState, '0x1')).toStrictEqual(
[],
);
});
});

describe('getAddressBookEntryByNetwork', () => {
it('returns the address book entry for the given network and address', () => {
expect(
selectors.getAddressBookEntryByNetwork(
mockState,

'0xc42edfcc21ed14dda456aa0756c153f7985d8813',
'0x5',
),
).toStrictEqual({
address: '0xc42edfcc21ed14dda456aa0756c153f7985d8813',
chainId: '0x5',
isEns: false,
memo: '',
name: 'Address Book Account 1',
});
});

it('returns `undefined` if no entry is found for the given network and address', () => {
expect(
selectors.getAddressBookEntryByNetwork(
mockState,
'0xc42edfcc21ed14dda456aa0756c153f7985d8813',
'0x1',
),
).toBe(undefined);
});
});

describe('getAddressDisplayName', () => {
it('returns the account name for a hex address', () => {
expect(
Expand Down

0 comments on commit 240d3df

Please sign in to comment.