@@ -4447,13 +4447,10 @@ describe('custom log levels for username already exists error', () => {
44474447 infoSpy . calls . reset ( ) ;
44484448 } ) ;
44494449
4450- const testCases = [
4451- { logLevel : 'warn' , expectedSpy : 'warnSpy' } ,
4452- { logLevel : 'info' , expectedSpy : 'infoSpy' } ,
4453- ] ;
4450+ it ( 'should respect custom log levels for username already exists error' , async ( ) => {
4451+ const logLevels = [ 'warn' , 'info' ] ;
44544452
4455- testCases . forEach ( ( { logLevel, expectedSpy } ) => {
4456- it ( `should respect ${ logLevel } log level for username already exists error` , async ( ) => {
4453+ for ( const logLevel of logLevels ) {
44574454 await reconfigureServer ( {
44584455 logLevels : {
44594456 usernameAlreadyExists : logLevel ,
@@ -4473,15 +4470,23 @@ describe('custom log levels for username already exists error', () => {
44734470
44744471 try {
44754472 await duplicateUser . signUp ( ) ;
4473+ fail ( 'Should have thrown an error' ) ;
44764474 } catch ( error ) {
44774475 expect ( error . code ) . toBe ( Parse . Error . USERNAME_TAKEN ) ;
4478- expect ( this [ expectedSpy ] ) . toHaveBeenCalled ( ) ;
4479- [ 'warnSpy' , 'errorSpy' , 'infoSpy' ] . forEach ( spy => {
4480- if ( spy !== expectedSpy ) {
4481- expect ( this [ spy ] ) . not . toHaveBeenCalled ( ) ;
4482- }
4483- } ) ;
4476+ if ( logLevel === 'warn' ) {
4477+ expect ( warnSpy ) . toHaveBeenCalled ( ) ;
4478+ expect ( infoSpy ) . not . toHaveBeenCalled ( ) ;
4479+ } else if ( logLevel === 'info' ) {
4480+ expect ( infoSpy ) . toHaveBeenCalled ( ) ;
4481+ expect ( warnSpy ) . not . toHaveBeenCalled ( ) ;
4482+ }
4483+ expect ( errorSpy ) . not . toHaveBeenCalled ( ) ;
44844484 }
4485- } ) ;
4485+
4486+ // Reset spies for the next iteration
4487+ warnSpy . calls . reset ( ) ;
4488+ errorSpy . calls . reset ( ) ;
4489+ infoSpy . calls . reset ( ) ;
4490+ }
44864491 } ) ;
44874492} ) ;
0 commit comments