File tree Expand file tree Collapse file tree 1 file changed +19
-17
lines changed
exercises/practice/bank-account Expand file tree Collapse file tree 1 file changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -137,32 +137,34 @@ describe('Bank Account', () => {
137137 const account = new BankAccount ( ) ;
138138 account . open ( ) ;
139139 account . deposit ( 1000 ) ;
140-
140+
141141 for ( let i = 0 ; i < 10 ; i ++ ) {
142142 await adjustBalanceConcurrently ( account ) ;
143143 expect ( account . balance ) . toEqual ( 1000 ) ;
144144 }
145145 } ) ;
146-
146+
147147 function adjustBalanceConcurrently ( account ) {
148148 const random = ( ) => Math . floor ( Math . random ( ) * 10 ) ;
149-
150- const tasks = Array . from ( { length : 1000 } , ( ) =>
151- new Promise ( resolve => {
152- try {
153- account . deposit ( 5 ) ;
154- setTimeout ( ( ) => {
155- account . withdraw ( 5 ) ;
156- resolve ( ) ;
157- } , random ( ) ) ;
158- } catch ( e ) {
159- throw new Error ( `Exception should not be thrown: ${ e . message } ` ) ;
160- }
161- } )
149+
150+ const tasks = Array . from (
151+ { length : 1000 } ,
152+ ( ) =>
153+ new Promise ( ( resolve ) => {
154+ try {
155+ account . deposit ( 5 ) ;
156+ setTimeout ( ( ) => {
157+ account . withdraw ( 5 ) ;
158+ resolve ( ) ;
159+ } , random ( ) ) ;
160+ } catch ( e ) {
161+ throw new Error ( `Exception should not be thrown: ${ e . message } ` ) ;
162+ }
163+ } ) ,
162164 ) ;
163-
165+
164166 return Promise . all ( tasks ) ;
165- }
167+ }
166168
167169 xtest ( 'Changing balance directly throws error' , ( ) => {
168170 const account = new BankAccount ( ) ;
You can’t perform that action at this time.
0 commit comments