Skip to content

Commit d0d3563

Browse files
committed
Make translate required in getCompanyCardDescription
1 parent 8afed52 commit d0d3563

2 files changed

Lines changed: 5 additions & 19 deletions

File tree

src/libs/CardUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ function getCardDescriptionForSearchTable(card: Card, translate: LocalizedTransl
202202
* @param translate
203203
* @returns company card name
204204
*/
205-
function getCompanyCardDescription(transactionCardName?: string, cardID?: number, cards?: CardList, translate?: LocalizedTranslate) {
205+
function getCompanyCardDescription(transactionCardName: string | undefined, cardID: number | undefined, cards: CardList | undefined, translate: LocalizedTranslate) {
206206
if (!cardID || !cards?.[cardID]) {
207207
return transactionCardName;
208208
}
209209
const card = cards[cardID];
210-
if (isTravelCard(card) && translate) {
210+
if (isTravelCard(card)) {
211211
return translate('cardTransactions.centralInvoicing');
212212
}
213213
if (isExpensifyCard(card)) {

tests/unit/CardUtilsTest.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,16 +2947,16 @@ describe('CardUtils', () => {
29472947
},
29482948
};
29492949
it('should return the correct description for a company card', () => {
2950-
const description = getCompanyCardDescription('Test', 21310091, cardList);
2950+
const description = getCompanyCardDescription('Test', 21310091, cardList, mockTranslate);
29512951
expect(description).toBe('480801XXXXXX2554');
29522952
});
29532953

29542954
it('should return the correct description for an Expensify card', () => {
2955-
const description = getCompanyCardDescription('Test', 21570657, cardList);
2955+
const description = getCompanyCardDescription('Test', 21570657, cardList, mockTranslate);
29562956
expect(description).toBe('Test');
29572957
});
29582958

2959-
it('should return "Central invoicing" for a travel card when translate is provided', () => {
2959+
it('should return "Central invoicing" for a travel card', () => {
29602960
const travelCardList = {
29612961
'99999': {
29622962
cardID: 99999,
@@ -2969,20 +2969,6 @@ describe('CardUtils', () => {
29692969
const description = getCompanyCardDescription('Expensify Card - 6909', 99999, travelCardList, mockTranslate);
29702970
expect(description).toBe('Central invoicing');
29712971
});
2972-
2973-
it('should return raw card name for a travel card when translate is not provided', () => {
2974-
const travelCardList = {
2975-
'99999': {
2976-
cardID: 99999,
2977-
bank: CONST.EXPENSIFY_CARD.BANK,
2978-
nameValuePairs: {
2979-
feedCountry: CONST.TRAVEL.PROGRAM_TRAVEL_US,
2980-
},
2981-
},
2982-
} as unknown as CardList;
2983-
const description = getCompanyCardDescription('Expensify Card - 6909', 99999, travelCardList);
2984-
expect(description).toBe('Expensify Card - 6909');
2985-
});
29862972
});
29872973

29882974
describe('Expensify card sort comparator', () => {

0 commit comments

Comments
 (0)