|
1 | 1 | import {buildFeedKeysWithAssignedCards, isExpensifyCardUkEuSupportedSelector} from '@selectors/Card'; |
2 | 2 | import lodashSortBy from 'lodash/sortBy'; |
3 | 3 | import type {OnyxCollection} from 'react-native-onyx'; |
| 4 | +import type {LocalizedTranslate} from '@components/LocaleContextProvider'; |
4 | 5 | import type {FeedKeysWithAssignedCards} from '@hooks/useFeedKeysWithAssignedCards'; |
5 | 6 | import type IllustrationsType from '@styles/theme/illustrations/types'; |
6 | 7 | import CONST from '@src/CONST'; |
@@ -2912,6 +2913,12 @@ describe('CardUtils', () => { |
2912 | 2913 | }); |
2913 | 2914 |
|
2914 | 2915 | describe('getCompanyCardDescription', () => { |
| 2916 | + const mockTranslate = ((key: string) => { |
| 2917 | + if (key === 'cardTransactions.centralInvoicing') { |
| 2918 | + return 'Central invoicing'; |
| 2919 | + } |
| 2920 | + return key; |
| 2921 | + }) as LocalizedTranslate; |
2915 | 2922 | const cardList: CardList = { |
2916 | 2923 | '21310091': { |
2917 | 2924 | accountID: 18439984, |
@@ -2948,6 +2955,34 @@ describe('CardUtils', () => { |
2948 | 2955 | const description = getCompanyCardDescription('Test', 21570657, cardList); |
2949 | 2956 | expect(description).toBe('Test'); |
2950 | 2957 | }); |
| 2958 | + |
| 2959 | + it('should return "Central invoicing" for a travel card when translate is provided', () => { |
| 2960 | + const travelCardList = { |
| 2961 | + '99999': { |
| 2962 | + cardID: 99999, |
| 2963 | + bank: CONST.EXPENSIFY_CARD.BANK, |
| 2964 | + nameValuePairs: { |
| 2965 | + feedCountry: CONST.TRAVEL.PROGRAM_TRAVEL_US, |
| 2966 | + }, |
| 2967 | + }, |
| 2968 | + } as unknown as CardList; |
| 2969 | + const description = getCompanyCardDescription('Expensify Card - 6909', 99999, travelCardList, mockTranslate); |
| 2970 | + expect(description).toBe('Central invoicing'); |
| 2971 | + }); |
| 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 | + }); |
2951 | 2986 | }); |
2952 | 2987 |
|
2953 | 2988 | describe('Expensify card sort comparator', () => { |
|
0 commit comments