@@ -2930,4 +2930,36 @@ describe('TransactionUtils', () => {
29302930 expect ( TransactionUtils . getExchangeRate ( transaction ) ) . toBe ( '1.25 USD/EUR' ) ;
29312931 } ) ;
29322932 } ) ;
2933+
2934+ describe ( 'shouldClearConvertedAmount' , ( ) => {
2935+ it ( 'returns false when destinationCurrency is undefined' , ( ) => {
2936+ const transaction = generateTransaction ( { currency : 'USD' } ) ;
2937+ expect ( TransactionUtils . shouldClearConvertedAmount ( transaction , 'EUR' , undefined ) ) . toBe ( false ) ;
2938+ } ) ;
2939+
2940+ it ( 'returns false when sourceCurrency equals destinationCurrency' , ( ) => {
2941+ const transaction = generateTransaction ( { currency : 'USD' } ) ;
2942+ expect ( TransactionUtils . shouldClearConvertedAmount ( transaction , 'EUR' , 'EUR' ) ) . toBe ( false ) ;
2943+ } ) ;
2944+
2945+ it ( 'returns false when transactionCurrency equals destinationCurrency' , ( ) => {
2946+ const transaction = generateTransaction ( { currency : 'EUR' } ) ;
2947+ expect ( TransactionUtils . shouldClearConvertedAmount ( transaction , 'USD' , 'EUR' ) ) . toBe ( false ) ;
2948+ } ) ;
2949+
2950+ it ( 'returns true when both sourceCurrency and transactionCurrency differ from destinationCurrency' , ( ) => {
2951+ const transaction = generateTransaction ( { currency : 'GBP' } ) ;
2952+ expect ( TransactionUtils . shouldClearConvertedAmount ( transaction , 'USD' , 'EUR' ) ) . toBe ( true ) ;
2953+ } ) ;
2954+
2955+ it ( 'falls back to transactionCurrency when sourceCurrency is undefined and currencies differ' , ( ) => {
2956+ const transaction = generateTransaction ( { currency : 'GBP' } ) ;
2957+ expect ( TransactionUtils . shouldClearConvertedAmount ( transaction , undefined , 'EUR' ) ) . toBe ( true ) ;
2958+ } ) ;
2959+
2960+ it ( 'returns false when sourceCurrency is undefined and transactionCurrency matches destinationCurrency' , ( ) => {
2961+ const transaction = generateTransaction ( { currency : 'EUR' } ) ;
2962+ expect ( TransactionUtils . shouldClearConvertedAmount ( transaction , undefined , 'EUR' ) ) . toBe ( false ) ;
2963+ } ) ;
2964+ } ) ;
29332965} ) ;
0 commit comments