@@ -10,8 +10,10 @@ import {
1010 formatCardExpiration ,
1111 getBankCardDetailsImage ,
1212 getBankName ,
13+ getCardDescription ,
1314 getCardFeedIcon ,
1415 getCardsByCardholderName ,
16+ getCompanyCardDescription ,
1517 getCompanyFeeds ,
1618 getCustomOrFormattedFeedName ,
1719 getFeedType ,
@@ -21,12 +23,13 @@ import {
2123 getYearFromExpirationDateString ,
2224 hasIssuedExpensifyCard ,
2325 isCustomFeed as isCustomFeedCardUtils ,
26+ isExpensifyCard ,
2427 isExpensifyCardFullySetUp ,
2528 lastFourNumbersFromCardName ,
2629 maskCardNumber ,
2730 sortCardsByCardholderName ,
2831} from '@src/libs/CardUtils' ;
29- import type { CardFeeds , CardList , CompanyCardFeed , ExpensifyCardSettings , PersonalDetailsList , Policy , WorkspaceCardsList } from '@src/types/onyx' ;
32+ import type { Card , CardFeeds , CardList , CompanyCardFeed , ExpensifyCardSettings , PersonalDetailsList , Policy , WorkspaceCardsList } from '@src/types/onyx' ;
3033import type { CompanyCardFeedWithNumber } from '@src/types/onyx/CardFeeds' ;
3134import { localeCompare } from '../utils/TestHelper' ;
3235import waitForBatchedUpdates from '../utils/waitForBatchedUpdates' ;
@@ -1024,4 +1027,115 @@ describe('CardUtils', () => {
10241027 expect ( sortedCards . at ( 0 ) ?. cardID ) . toBe ( 1 ) ;
10251028 } ) ;
10261029 } ) ;
1030+
1031+ describe ( 'getCardDescription' , ( ) => {
1032+ it ( 'should return the correct card description for company card' , ( ) => {
1033+ const card : Card = {
1034+ accountID : 18439984 ,
1035+ bank : CONST . COMPANY_CARD . FEED_BANK_NAME . VISA ,
1036+ cardID : 21310091 ,
1037+ cardName : '480801XXXXXX2554' ,
1038+ domainName : 'expensify-policy41314f4dc5ce25af.exfy' ,
1039+ fraud : 'none' ,
1040+ lastFourPAN : '2554' ,
1041+ lastUpdated : '' ,
1042+ lastScrape : '2024-11-27 11:00:53' ,
1043+ scrapeMinDate : '2024-10-17' ,
1044+ state : 3 ,
1045+ } ;
1046+ const description = getCardDescription ( card ) ;
1047+ expect ( description ) . toBe ( 'Visa - 2554' ) ;
1048+ } ) ;
1049+
1050+ it ( 'should return the correct card description for Expensify card' , ( ) => {
1051+ const card : Card = {
1052+ accountID : 18439984 ,
1053+ bank : CONST . EXPENSIFY_CARD . BANK ,
1054+ cardID : 21570657 ,
1055+ cardName : 'CREDIT CARD...5644' ,
1056+ domainName : 'expensify-policy17f617b9fe23d2f1.exfy' ,
1057+ fraud : 'none' ,
1058+ lastFourPAN : '' ,
1059+ lastScrape : '' ,
1060+ lastUpdated : '' ,
1061+ state : 2 ,
1062+ } ;
1063+ const description = getCardDescription ( card ) ;
1064+ expect ( description ) . toBe ( 'Expensify Card' ) ;
1065+ } ) ;
1066+ } ) ;
1067+
1068+ describe ( 'isExpensifyCard' , ( ) => {
1069+ it ( 'should return true for Expensify Card' , ( ) => {
1070+ const card : Card = {
1071+ accountID : 18439984 ,
1072+ bank : CONST . EXPENSIFY_CARD . BANK ,
1073+ cardID : 21570657 ,
1074+ cardName : 'CREDIT CARD...5644' ,
1075+ domainName : 'expensify-policy17f617b9fe23d2f1.exfy' ,
1076+ fraud : 'none' ,
1077+ lastFourPAN : '' ,
1078+ lastScrape : '' ,
1079+ lastUpdated : '' ,
1080+ state : 2 ,
1081+ } ;
1082+ expect ( isExpensifyCard ( card ) ) . toBe ( true ) ;
1083+ } ) ;
1084+
1085+ it ( 'should return false for non-Expensify Card' , ( ) => {
1086+ const card : Card = {
1087+ accountID : 18439984 ,
1088+ bank : CONST . COMPANY_CARD . FEED_BANK_NAME . VISA ,
1089+ cardID : 21310091 ,
1090+ cardName : '480801XXXXXX2554' ,
1091+ domainName : 'expensify-policy41314f4dc5ce25af.exfy' ,
1092+ fraud : 'none' ,
1093+ lastFourPAN : '2554' ,
1094+ lastUpdated : '' ,
1095+ lastScrape : '2024-11-27 11:00:53' ,
1096+ scrapeMinDate : '2024-10-17' ,
1097+ state : 3 ,
1098+ } ;
1099+ expect ( isExpensifyCard ( card ) ) . toBe ( false ) ;
1100+ } ) ;
1101+ } ) ;
1102+
1103+ describe ( 'getCompanyCardDescription' , ( ) => {
1104+ const cardList : CardList = {
1105+ '21310091' : {
1106+ accountID : 18439984 ,
1107+ bank : CONST . COMPANY_CARD . FEED_BANK_NAME . VISA ,
1108+ cardID : 21310091 ,
1109+ cardName : '480801XXXXXX2554' ,
1110+ domainName : 'expensify-policy41314f4dc5ce25af.exfy' ,
1111+ fraud : 'none' ,
1112+ lastFourPAN : '2554' ,
1113+ lastUpdated : '' ,
1114+ lastScrape : '2024-11-27 11:00:53' ,
1115+ scrapeMinDate : '2024-10-17' ,
1116+ state : 3 ,
1117+ } ,
1118+ '21570657' : {
1119+ accountID : 18439984 ,
1120+ bank : CONST . EXPENSIFY_CARD . BANK ,
1121+ cardID : 21570657 ,
1122+ cardName : 'CREDIT CARD...5644' ,
1123+ domainName : 'expensify-policy17f617b9fe23d2f1.exfy' ,
1124+ fraud : 'none' ,
1125+ lastFourPAN : '' ,
1126+ lastScrape : '' ,
1127+ lastUpdated : '' ,
1128+ state : 2 ,
1129+ } ,
1130+ } ;
1131+ it ( 'should return the correct description for a company card' , ( ) => {
1132+ const description = getCompanyCardDescription ( 'Test' , 21310091 , cardList ) ;
1133+ expect ( description ) . toBe ( '480801XXXXXX2554' ) ;
1134+ } ) ;
1135+
1136+ it ( 'should return the correct description for an Expensify card' , ( ) => {
1137+ const description = getCompanyCardDescription ( 'Test' , 21570657 , cardList ) ;
1138+ expect ( description ) . toBe ( 'Test' ) ;
1139+ } ) ;
1140+ } ) ;
10271141} ) ;
0 commit comments