@@ -906,45 +906,59 @@ describe('BrokerLoansTable Component', () => {
906906 * =========================================
907907 * Verify currency is passed through to LoanRow.
908908 */
909- describe ( 'Currency Prop' , ( ) => {
910- it ( 'passes currency to loan rows' , ( ) => {
911- const loans = [ createMockLoan ( { TotalValueOutstanding : '1000' } ) ]
909+ describe ( 'Currency Prop tests' , ( ) => {
910+ it ( 'renders correctly with non-XRP/non-USD currency' , ( ) => {
911+ // Test with EUR - an arbitrary IOU currency that is neither XRP nor RLUSD
912+ // This ensures the component handles any currency type correctly
913+ const loans = [
914+ createMockLoan ( {
915+ index : 'LOAN_EUR_1' ,
916+ PrincipalOutstanding : '5000' ,
917+ TotalValueOutstanding : '5250' ,
918+ } ) ,
919+ ]
912920
913- render (
921+ const { container } = render (
914922 < TestWrapper >
915923 < BrokerLoansTable
916924 loans = { loans }
917- currency = "RLUSD "
918- displayCurrency = { defaultDisplayCurrency }
919- asset = { { currency : 'RLUSD ' , issuer : 'rTestIssuer' } }
925+ currency = "EUR "
926+ displayCurrency = "EUR"
927+ asset = { { currency : 'EUR ' , issuer : 'rTestIssuer' } }
920928 />
921929 </ TestWrapper > ,
922930 )
923931
924- // The amount cells should include the currency (amount-requested and outstanding-balance)
925- // Using getAllByText since currency appears in multiple columns
926- const elementsWithCurrency = screen . getAllByText ( / R L U S D / )
927- expect ( elementsWithCurrency . length ) . toBeGreaterThan ( 0 )
932+ // Table should render with loan row
933+ expect ( container . querySelector ( '.loan-row' ) ) . toBeInTheDocument ( )
934+
935+ // Verify the amount-requested and outstanding-balance cells display EUR values
936+ const loanRow = container . querySelector ( '.loan-row' ) !
937+ const amountRequested = loanRow . querySelector ( '.amount-requested' )
938+ const outstandingBalance = loanRow . querySelector ( '.outstanding-balance' )
939+ expect ( amountRequested ) . toHaveTextContent ( '5,250.00 EUR' )
940+ expect ( outstandingBalance ) . toHaveTextContent ( '5,250.00 EUR' )
928941 } )
929942
930- it ( 'renders correctly with non-XRP/non-RLUSD currency' , ( ) => {
931- // Test with EUR - an arbitrary IOU currency that is neither XRP nor RLUSD
932- // This ensures the component handles any currency type correctly
943+ it ( `Render the BrokerLoans table with BTC exotic currency` , ( ) => {
933944 const loans = [
934945 createMockLoan ( {
935- index : 'LOAN_EUR_1 ' ,
946+ index : 'LOAN_BTC_1 ' ,
936947 PrincipalOutstanding : '5000' ,
937948 TotalValueOutstanding : '5250' ,
938949 } ) ,
939950 ]
940951
952+ const btcAsset = { currency : 'BTC' , issuer : 'rTestIssuer' }
953+
941954 const { container } = render (
942955 < TestWrapper >
943956 < BrokerLoansTable
944957 loans = { loans }
945- currency = "EUR"
946- displayCurrency = { defaultDisplayCurrency }
947- asset = { { currency : 'EUR' , issuer : 'rTestIssuer' } }
958+ currency = { btcAsset . currency }
959+ displayCurrency = { btcAsset . currency }
960+ asset = { btcAsset }
961+ isCurrencySpecialSymbol = { isCurrencyExoticSymbol ( btcAsset . currency ) }
948962 />
949963 </ TestWrapper > ,
950964 )
@@ -953,15 +967,15 @@ describe('BrokerLoansTable Component', () => {
953967 expect ( container . querySelector ( '.loan-row' ) ) . toBeInTheDocument ( )
954968
955969 // Currency should appear in the amount columns
956- const elementsWithCurrency = screen . getAllByText ( / E U R / )
970+ const elementsWithCurrency = screen . getAllByText ( / \u20BF 5 , 2 5 0 . 0 0 / )
957971 expect ( elementsWithCurrency . length ) . toBeGreaterThan ( 0 )
958972
959973 // Verify XRP and USD do not appear - ensures EUR is used throughout
960974 expect ( screen . queryByText ( / X R P / ) ) . not . toBeInTheDocument ( )
961975 expect ( screen . queryByText ( / U S D / ) ) . not . toBeInTheDocument ( )
962976 } )
963977
964- it ( `Render the BrokerLoans table with BTC exotic currency` , ( ) => {
978+ it ( `display a BTC-denominated Loan in USD currency` , ( ) => {
965979 const loans = [
966980 createMockLoan ( {
967981 index : 'LOAN_BTC_1' ,
@@ -977,7 +991,7 @@ describe('BrokerLoansTable Component', () => {
977991 < BrokerLoansTable
978992 loans = { loans }
979993 currency = { btcAsset . currency }
980- displayCurrency = { btcAsset . currency }
994+ displayCurrency = "USD"
981995 asset = { btcAsset }
982996 isCurrencySpecialSymbol = { isCurrencyExoticSymbol ( btcAsset . currency ) }
983997 />
@@ -986,31 +1000,63 @@ describe('BrokerLoansTable Component', () => {
9861000
9871001 // Table should render with loan row
9881002 expect ( container . querySelector ( '.loan-row' ) ) . toBeInTheDocument ( )
1003+ const loanRow = container . querySelector ( '.loan-row' ) !
1004+ const amountRequested = loanRow . querySelector ( '.amount-requested' )
1005+ const outstandingBalance = loanRow . querySelector ( '.outstanding-balance' )
1006+ expect ( amountRequested ) . toHaveTextContent ( '$7,875.00 USD' )
1007+ expect ( outstandingBalance ) . toHaveTextContent ( '$7,875.00 USD' )
1008+ } )
9891009
990- // Currency should appear in the amount columns
991- const elementsWithCurrency = screen . getAllByText ( / \u20BF 5 , 2 5 0 .0 0 / )
992- expect ( elementsWithCurrency . length ) . toBeGreaterThan ( 0 )
1010+ it ( 'display a XRP-denominated Loan in XRP currency' , ( ) => {
1011+ const loans = [ createMockLoan ( ) ]
9931012
994- // Verify XRP and USD do not appear - ensures EUR is used throughout
995- expect ( screen . queryByText ( / X R P / ) ) . not . toBeInTheDocument ( )
996- expect ( screen . queryByText ( / U S D / ) ) . not . toBeInTheDocument ( )
1013+ // This should not throw - currency defaults to XRP because XRP is the asset of the Vault.
1014+ const { container } = render (
1015+ < TestWrapper >
1016+ < BrokerLoansTable
1017+ loans = { loans }
1018+ currency = { defaultAsset . currency }
1019+ displayCurrency = { defaultDisplayCurrency }
1020+ asset = { defaultAsset }
1021+ isCurrencySpecialSymbol = { isCurrencyExoticSymbol (
1022+ defaultAsset . currency ,
1023+ ) }
1024+ />
1025+ </ TestWrapper > ,
1026+ )
1027+
1028+ // Verify the amount-requested and outstanding-balance cells display EUR values
1029+ const loanRow = container . querySelector ( '.loan-row' ) !
1030+ const amountRequested = loanRow . querySelector ( '.amount-requested' )
1031+ const outstandingBalance = loanRow . querySelector ( '.outstanding-balance' )
1032+ expect ( amountRequested ) . toHaveTextContent ( '\uE900 10.5K' )
1033+ expect ( outstandingBalance ) . toHaveTextContent ( '\uE900 10.5K' )
9971034 } )
9981035
999- it ( 'defaults to empty string when currency not provided' , ( ) => {
1036+ it ( `display a XRP-denominated Loan in USD currency` , ( ) => {
10001037 const loans = [ createMockLoan ( ) ]
10011038
1002- // This should not throw - currency defaults to ''
1003- expect ( ( ) =>
1004- render (
1005- < TestWrapper >
1006- < BrokerLoansTable
1007- loans = { loans }
1008- displayCurrency = { defaultDisplayCurrency }
1009- asset = { defaultAsset }
1010- />
1011- </ TestWrapper > ,
1012- ) ,
1013- ) . not . toThrow ( )
1039+ // This should not throw - currency defaults to XRP because XRP is the asset of the Vault.
1040+ const { container } = render (
1041+ < TestWrapper >
1042+ < BrokerLoansTable
1043+ loans = { loans }
1044+ currency = { defaultAsset . currency }
1045+ displayCurrency = "USD"
1046+ asset = { defaultAsset }
1047+ isCurrencySpecialSymbol = { isCurrencyExoticSymbol (
1048+ defaultAsset . currency ,
1049+ ) }
1050+ />
1051+ </ TestWrapper > ,
1052+ )
1053+
1054+ // Verify the amount-requested and outstanding-balance cells display EUR values
1055+ const loanRow = container . querySelector ( '.loan-row' ) !
1056+ const amountRequested = loanRow . querySelector ( '.amount-requested' )
1057+ const outstandingBalance = loanRow . querySelector ( '.outstanding-balance' )
1058+ expect ( amountRequested ) . toHaveTextContent ( '$15.8K USD' )
1059+ expect ( outstandingBalance ) . toHaveTextContent ( '$15.8K USD' )
10141060 } )
10151061 } )
10161062} )
0 commit comments