@@ -33,10 +33,13 @@ import {
3333 TenantAwareAuth , UpdatePhoneMultiFactorInfoRequest , UpdateTenantRequest , UserImportOptions ,
3434 UserImportRecord , UserRecord , getAuth , UpdateProjectConfigRequest , UserMetadata ,
3535} from '../../lib/auth/index' ;
36+ import * as sinon from 'sinon' ;
37+ import * as sinonChai from 'sinon-chai' ;
3638
3739const chalk = require ( 'chalk' ) ; // eslint-disable-line @typescript-eslint/no-var-requires
3840
3941chai . should ( ) ;
42+ chai . use ( sinonChai ) ;
4043chai . use ( chaiAsPromised ) ;
4144
4245const expect = chai . expect ;
@@ -103,6 +106,7 @@ function clientAuth(): FirebaseAuth {
103106describe ( 'admin.auth' , ( ) => {
104107
105108 let uidFromCreateUserWithoutUid : string ;
109+ const processWarningSpy = sinon . spy ( ) ;
106110
107111 before ( ( ) => {
108112 firebase . initializeApp ( {
@@ -112,10 +116,24 @@ describe('admin.auth', () => {
112116 if ( authEmulatorHost ) {
113117 ( clientAuth ( ) as any ) . useEmulator ( 'http://' + authEmulatorHost ) ;
114118 }
119+ process . on ( 'warning' , processWarningSpy ) ;
115120 return cleanup ( ) ;
116121 } ) ;
117122
123+ afterEach ( ( ) => {
124+ expect (
125+ processWarningSpy . neverCalledWith (
126+ sinon . match (
127+ ( warning : Error ) => warning . name === 'MaxListenersExceededWarning'
128+ )
129+ ) ,
130+ 'process.on("warning") was called with an unexpected MaxListenersExceededWarning.'
131+ ) . to . be . true ;
132+ processWarningSpy . resetHistory ( ) ;
133+ } ) ;
134+
118135 after ( ( ) => {
136+ process . removeListener ( 'warning' , processWarningSpy ) ;
119137 return cleanup ( ) ;
120138 } ) ;
121139
0 commit comments