@@ -70,31 +70,7 @@ describe("SitePreferences", () => {
7070 name : "Save" ,
7171 } ) ;
7272
73- const checkDualInputValues = ( values : Array < [ number , string ] > ) => {
74- for ( let i = 0 ; i < values . length ; i ++ ) {
75- expect ( mockGetFormattedInCurrency ) . toHaveBeenNthCalledWith (
76- i + 1 ,
77- ...values [ i ]
78- ) ;
79- }
80- expect ( mockGetFormattedInCurrency ) . toHaveBeenCalledTimes ( values . length ) ;
81- } ;
82-
83- const checkDualInputValue = ( v : number , n : number ) => {
84- for ( let i = 1 ; i <= n * 2 ; i += 2 ) {
85- expect ( mockGetFormattedInCurrency ) . toHaveBeenNthCalledWith ( i , v , "BTC" ) ;
86- expect ( mockGetFormattedInCurrency ) . toHaveBeenNthCalledWith (
87- i + 1 ,
88- v ,
89- "USD"
90- ) ;
91- }
92- expect ( mockGetFormattedInCurrency ) . toHaveBeenCalledTimes ( n * 2 ) ;
93- } ;
94-
95- // update fiat value when modal is open
96- checkDualInputValue ( defaultProps . allowance . totalBudget , 2 ) ;
97-
73+ // Budget input
9874 await act ( async ( ) => {
9975 await user . clear ( screen . getByLabelText ( "One-click payments budget" ) ) ;
10076 mockGetFormattedInCurrency . mockClear ( ) ;
@@ -107,23 +83,11 @@ describe("SitePreferences", () => {
10783 // update fiat value
10884 expect ( screen . getByLabelText ( "One-click payments budget" ) ) . toHaveValue ( 250 ) ;
10985
110- checkDualInputValues ( [
111- [ 2 , "BTC" ] ,
112- [ 2 , "USD" ] ,
113- [ 2 , "BTC" ] ,
114- [ 2 , "USD" ] ,
115- [ 25 , "BTC" ] ,
116- [ 25 , "USD" ] ,
117- [ 25 , "BTC" ] ,
118- [ 25 , "USD" ] ,
119- [ 250 , "BTC" ] ,
120- [ 250 , "USD" ] ,
121- [ 250 , "BTC" ] ,
122- [ 250 , "USD" ] ,
123- [ 250 , "BTC" ] ,
124- [ 250 , "USD" ] ,
125- ] ) ;
86+ // Final formatting check — just once each
87+ expect ( mockGetFormattedInCurrency ) . toHaveBeenCalledWith ( 250 , "BTC" ) ;
88+ expect ( mockGetFormattedInCurrency ) . toHaveBeenCalledWith ( 250 , "USD" ) ;
12689
90+ // Save
12791 await act ( async ( ) => {
12892 await user . click ( saveButton ) ;
12993 } ) ;
0 commit comments