@@ -33,10 +33,13 @@ import {
33
33
TenantAwareAuth , UpdatePhoneMultiFactorInfoRequest , UpdateTenantRequest , UserImportOptions ,
34
34
UserImportRecord , UserRecord , getAuth , UpdateProjectConfigRequest , UserMetadata ,
35
35
} from '../../lib/auth/index' ;
36
+ import * as sinon from 'sinon' ;
37
+ import * as sinonChai from 'sinon-chai' ;
36
38
37
39
const chalk = require ( 'chalk' ) ; // eslint-disable-line @typescript-eslint/no-var-requires
38
40
39
41
chai . should ( ) ;
42
+ chai . use ( sinonChai ) ;
40
43
chai . use ( chaiAsPromised ) ;
41
44
42
45
const expect = chai . expect ;
@@ -103,6 +106,7 @@ function clientAuth(): FirebaseAuth {
103
106
describe ( 'admin.auth' , ( ) => {
104
107
105
108
let uidFromCreateUserWithoutUid : string ;
109
+ const processWarningSpy = sinon . spy ( ) ;
106
110
107
111
before ( ( ) => {
108
112
firebase . initializeApp ( {
@@ -112,10 +116,24 @@ describe('admin.auth', () => {
112
116
if ( authEmulatorHost ) {
113
117
( clientAuth ( ) as any ) . useEmulator ( 'http://' + authEmulatorHost ) ;
114
118
}
119
+ process . on ( 'warning' , processWarningSpy ) ;
115
120
return cleanup ( ) ;
116
121
} ) ;
117
122
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
+
118
135
after ( ( ) => {
136
+ process . removeListener ( 'warning' , processWarningSpy ) ;
119
137
return cleanup ( ) ;
120
138
} ) ;
121
139
0 commit comments