Skip to content

Commit

Permalink
Add getCustomOrFormattedFeedName tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VickyStash committed Nov 13, 2024
1 parent b75026f commit 668b6cb
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/unit/CardUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ const directFeeds = {
},
};
const allFeeds: CompanyFeeds = {...customFeeds, ...directFeeds};
const customFeedName = 'Custom feed name';

const cardFeedsCollection: OnyxCollection<OnyxTypes.CardFeeds> = {
FAKE_ID_1: {
settings: {
companyCardNicknames: {
[CONST.COMPANY_CARD.FEED_BANK_NAME.VISA]: customFeedName,
},
companyCards: customFeeds,
oAuthAccountDetails: directFeeds,
},
Expand Down Expand Up @@ -176,4 +180,27 @@ describe('CardUtils', () => {
expect(selectedFeed).toBe(undefined);
});
});

describe('getCustomOrFormattedFeedName', () => {
it('Should return custom name if exists', () => {
const feed = CONST.COMPANY_CARD.FEED_BANK_NAME.VISA;
const companyCardNicknames = cardFeedsCollection.FAKE_ID_1?.settings?.companyCardNicknames;
const feedName = CardUtils.getCustomOrFormattedFeedName(feed, companyCardNicknames);
expect(feedName).toBe(customFeedName);
});

it('Should return formatted name if there is no custom name', () => {
const feed = CONST.COMPANY_CARD.FEED_BANK_NAME.VISA;
const companyCardNicknames = cardFeedsCollection.FAKE_ID_3?.settings?.companyCardNicknames;
const feedName = CardUtils.getCustomOrFormattedFeedName(feed, companyCardNicknames);
expect(feedName).toBe('Visa cards');
});

it('Should return undefined if no feed provided', () => {
const feed = undefined;
const companyCardNicknames = cardFeedsCollection.FAKE_ID_1?.settings?.companyCardNicknames;
const feedName = CardUtils.getCustomOrFormattedFeedName(feed, companyCardNicknames);
expect(feedName).toBe(undefined);
});
});
});

0 comments on commit 668b6cb

Please sign in to comment.