Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/libs/CardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ function getPlaidInstitutionIconUrl(feedName?: string) {
}

function getPlaidInstitutionId(feedName?: string) {
const feed = feedName?.split('.');
const feedNameWithoutDomainID = getCompanyCardFeed(feedName ?? '');
const feed = feedNameWithoutDomainID?.split('.');
if (!feed || feed?.at(0) !== CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID) {
return '';
}
Expand Down
36 changes: 36 additions & 0 deletions tests/unit/CardUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
getFilteredCardList,
getMonthFromExpirationDateString,
getOriginalCompanyFeeds,
getPlaidInstitutionIconUrl,
getPlaidInstitutionId,
getSelectedFeed,
getYearFromExpirationDateString,
hasIssuedExpensifyCard,
Expand Down Expand Up @@ -1340,4 +1342,38 @@ describe('CardUtils', () => {
expect(combinedKey).toBe(`${feedName}${CONST.COMPANY_CARD.FEED_KEY_SEPARATOR}${domainID}`);
});
});

describe('getPlaidInstitutionId', () => {
it('should return institution ID from plaid feed name without domain ID', () => {
const feedName = 'plaid.ins_123456';
const institutionId = getPlaidInstitutionId(feedName);
expect(institutionId).toBe('ins_123456');
});

it('should return institution ID from plaid feed name with domain ID', () => {
const feedName = 'plaid.ins_129663#12345';
const institutionId = getPlaidInstitutionId(feedName);
expect(institutionId).toBe('ins_129663');
});

it('should return empty string for non-plaid feed', () => {
const feedName = CONST.COMPANY_CARD.FEED_BANK_NAME.VISA;
const institutionId = getPlaidInstitutionId(feedName);
expect(institutionId).toBe('');
});
});

describe('getPlaidInstitutionIconUrl', () => {
it('should return correct icon URL for plaid feed without domain ID', () => {
const feedName = 'plaid.ins_123456';
const iconUrl = getPlaidInstitutionIconUrl(feedName);
expect(iconUrl).toBe(`${CONST.COMPANY_CARD_PLAID}ins_123456.png`);
});

it('should return correct icon URL for plaid feed with domain ID', () => {
const feedName = 'plaid.ins_129663#12345';
const iconUrl = getPlaidInstitutionIconUrl(feedName);
expect(iconUrl).toBe(`${CONST.COMPANY_CARD_PLAID}ins_129663.png`);
});
});
});
Loading