@@ -174,32 +174,50 @@ describe('wallet/Wallet Send Form', () => {
174174 return mock ;
175175 }
176176
177+ const MINIMUM_AMOUNT_UPDATED_MESSAGE_TEST_ID =
178+ 'WalletSendForm::minimumAmountNotice::updated' ;
179+
180+ function assertMinimumAmountNoticeMessage ( minimumAda : number ) {
181+ expect (
182+ screen . getByTestId ( MINIMUM_AMOUNT_UPDATED_MESSAGE_TEST_ID )
183+ ) . toHaveTextContent (
184+ `Note: the ada field was automatically updated because this transaction requires a minimum of ${ minimumAda } ADA.`
185+ ) ;
186+ }
187+
177188 test ( 'should update Ada input field to minimum required and restore to original value when tokens are removed' , async ( ) => {
178189 expect . assertions ( 4 ) ;
190+
179191 const minimumAda = 2 ;
180- const calculateTransactionFeeMock = createTransactionFeeMock ( 2 , minimumAda ) ;
192+ const calculateTransactionFeeMock = createTransactionFeeMock ( 1 , minimumAda ) ;
193+
181194 render (
182195 < SetupWallet calculateTransactionFee = { calculateTransactionFeeMock } />
183196 ) ;
197+
184198 enterReceiverAddress ( ) ;
199+
185200 const removeToken1 = await addToken ( ) ;
201+
186202 await waitForMinimumAdaRequiredMsg ( ) ;
187203 assertAdaInput ( minimumAda ) ;
204+
188205 const minimumAmountNoticeTestId =
189206 'WalletSendForm::minimumAmountNotice::updated' ;
207+
190208 expect ( screen . getByTestId ( minimumAmountNoticeTestId ) ) . toHaveTextContent (
191209 `Note: the ada field was automatically updated because this transaction requires a minimum of ${ minimumAda } ADA.`
192210 ) ;
211+
193212 await removeToken1 ( ) ;
194- const minimumAdaRequiredMsg = screen . getByTestId ( 'minimumAdaRequiredMsg' ) ;
195- await within ( minimumAdaRequiredMsg ) . findByText (
196- `to the minimum of 1 ADA required`
197- ) ;
198- assertAdaInput ( 0 ) ;
199- expect (
200- screen . queryByTestId ( minimumAmountNoticeTestId )
201- ) . not . toBeInTheDocument ( ) ;
213+
214+ await waitForMinimumAdaRequiredMsg ( 1 ) ;
215+
216+ assertAdaInput ( 1 ) ;
217+
218+ expect ( screen . queryByTestId ( minimumAmountNoticeTestId ) ) . toBeInTheDocument ( ) ;
202219 } ) ;
220+
203221 test ( 'should display an update button when Ada input field is less than minimum required' , async ( ) => {
204222 expect . assertions ( 3 ) ;
205223 const minimumAda = 2 ;
@@ -227,6 +245,7 @@ describe('wallet/Wallet Send Form', () => {
227245 await waitForElementToBeRemoved ( updateButton ) ;
228246 assertAdaInput ( minimumAda ) ;
229247 } ) ;
248+
230249 test ( 'should favour user Ada input instead of minimum required when the value is greater than the minimum one' , async ( ) => {
231250 expect . assertions ( 2 ) ;
232251 const minimumAda = 2.5 ;
@@ -253,6 +272,7 @@ describe('wallet/Wallet Send Form', () => {
253272 `Note: the ada field was automatically updated to ${ userAdaAmount } ADA because now it fulfills the minimum amount of 1 ADA for the transaction.`
254273 ) ;
255274 } ) ;
275+
256276 test ( 'should remove message when user entry is higher than minimum amount' , async ( ) => {
257277 expect . assertions ( 3 ) ;
258278 const minimumAda = 2.5 ;
@@ -287,6 +307,7 @@ describe('wallet/Wallet Send Form', () => {
287307 screen . queryByTestId ( minimumAmountNoticeTestId )
288308 ) . not . toBeInTheDocument ( ) ;
289309 } ) ;
310+
290311 test ( 'should not display any minimum amount notice message when ada input is greater than minimum amount' , async ( ) => {
291312 expect . assertions ( 2 ) ;
292313 const calculateTransactionFeeMock = jest . fn ( ) . mockResolvedValue ( {
@@ -311,6 +332,7 @@ describe('wallet/Wallet Send Form', () => {
311332 screen . findByTestId ( 'WalletSendForm::minimumAmountNotice::restored' )
312333 ) . rejects . toBeTruthy ( ) ;
313334 } ) ;
335+
314336 test ( 'should apply minimum fee to ada field when user has removed the previous update' , async ( ) => {
315337 expect . assertions ( 3 ) ;
316338 const minimumAda = 2 ;
@@ -334,6 +356,7 @@ describe('wallet/Wallet Send Form', () => {
334356 await waitForMinimumAdaRequiredMsg ( ) ;
335357 assertAdaInput ( minimumAda ) ;
336358 } ) ;
359+
337360 test ( 'should format ada input field using numeric format profile' , async ( ) => {
338361 expect . assertions ( 1 ) ;
339362 const minimumAda = 2 ;
@@ -350,6 +373,7 @@ describe('wallet/Wallet Send Form', () => {
350373 const adaInput = getInput ( 'Ada' ) ;
351374 expect ( adaInput ) . toHaveValue ( `${ minimumAda } ,000000` ) ;
352375 } ) ;
376+
353377 test ( 'should calculate transaction fee even when one of the assets are empty' , async ( ) => {
354378 expect . assertions ( 2 ) ;
355379 const minimumAda = 2 ;
@@ -365,4 +389,30 @@ describe('wallet/Wallet Send Form', () => {
365389 await waitForMinimumAdaRequiredMsg ( ) ;
366390 assertAdaInput ( minimumAda ) ;
367391 } ) ;
392+
393+ test ( 'should keep transaction fee when assets are removed and ada field is untouched' , async ( ) => {
394+ expect . assertions ( 3 ) ;
395+
396+ const fee = 2 ;
397+ const minimumAda = 1 ;
398+ const calculateTransactionFeeMock = createTransactionFeeMock ( 1 , fee ) ;
399+
400+ render (
401+ < SetupWallet calculateTransactionFee = { calculateTransactionFeeMock } />
402+ ) ;
403+
404+ enterReceiverAddress ( ) ;
405+
406+ const removeToken = await addToken ( ) ;
407+ await waitForMinimumAdaRequiredMsg ( ) ;
408+
409+ assertAdaInput ( fee ) ;
410+
411+ await removeToken ( ) ;
412+
413+ await waitForMinimumAdaRequiredMsg ( minimumAda ) ;
414+
415+ assertAdaInput ( minimumAda ) ;
416+ assertMinimumAmountNoticeMessage ( minimumAda ) ;
417+ } ) ;
368418} ) ;
0 commit comments