@@ -90,6 +90,44 @@ describe('EditDonation', () => {
9090 expect ( customRadioButton . checked ) . to . be . true ;
9191 } ) ;
9292
93+ it ( 'displays trailing 0 in custom amount where there is a 0 at the end' , async ( ) => {
94+ const el = ( await fixture ( html `
95+ < donation-form-edit-donation
96+ .donationInfo =${ new DonationPaymentInfo ( {
97+ amount : 2.4 ,
98+ donationType : DonationType . OneTime ,
99+ coverFees : false ,
100+ } ) }
101+ .amountOptions =${ [ 2 , 4 , 6 , 8 ] }
102+ > </ donation-form-edit-donation >
103+ ` ) ) as DonationFormEditDonation ;
104+ const customInput = el . shadowRoot ?. querySelector (
105+ '#custom-amount-input' ,
106+ ) as HTMLInputElement ;
107+ expect ( customInput ?. value ) . to . equal ( '2.40' ) ;
108+ } ) ;
109+
110+ it ( 'updates custom amount with trailing 0 on blur' , async ( ) => {
111+ const el = ( await fixture ( html `
112+ < donation-form-edit-donation
113+ .donationInfo =${ new DonationPaymentInfo ( {
114+ amount : 2.4 ,
115+ donationType : DonationType . OneTime ,
116+ coverFees : false ,
117+ } ) }
118+ .amountOptions =${ [ 2 , 4 , 6 , 8 ] }
119+ > </ donation-form-edit-donation >
120+ ` ) ) as DonationFormEditDonation ;
121+ const customInput = el . shadowRoot ?. querySelector (
122+ '#custom-amount-input' ,
123+ ) as HTMLInputElement ;
124+ customInput . value = '2.4' ;
125+ const blurEvent = new FocusEvent ( 'blur' ) ;
126+ customInput . dispatchEvent ( blurEvent ) ;
127+ await elementUpdated ( el ) ;
128+ expect ( customInput ?. value ) . to . equal ( '2.40' ) ;
129+ } ) ;
130+
93131 it ( 'emits donationInfoChanged event when cover fees checked' , async ( ) => {
94132 const el = ( await fixture ( html `
95133 < donation-form-edit-donation
0 commit comments