@@ -140,50 +140,46 @@ describe('FunctionsApiClient', () => {
140140
141141 delete process . env . CLOUD_TASKS_EMULATOR_HOST ;
142142
143- const prodStub = sinon
143+ const sendStub = sinon
144144 . stub ( HttpClient . prototype , 'send' )
145145 . resolves ( utils . responseFrom ( { } , 200 ) ) ;
146- stubs . push ( prodStub ) ;
146+ stubs . push ( sendStub ) ;
147147
148148 await prodClient . delete ( 'mock-task' , FUNCTION_NAME ) ;
149- expect ( prodStub ) . to . have . been . calledWith ( {
149+ await emulatorClient . delete ( 'mock-task' , FUNCTION_NAME ) ;
150+
151+ expect ( sendStub ) . to . have . been . calledTwice ;
152+ expect ( sendStub . firstCall ) . to . have . been . calledWith ( {
150153 method : 'DELETE' ,
151154 url : CLOUD_TASKS_URL . concat ( '/' , 'mock-task' ) ,
152155 headers : EXPECTED_HEADERS ,
153156 } ) ;
154-
155- prodStub . restore ( ) ;
156-
157- const emulatorStub = sinon
158- . stub ( HttpClient . prototype , 'send' )
159- . resolves ( utils . responseFrom ( { } , 200 ) ) ;
160- stubs . push ( emulatorStub ) ;
161-
162- await emulatorClient . delete ( 'mock-task' , FUNCTION_NAME ) ;
163- expect ( emulatorStub ) . to . have . been . calledWith ( {
157+ expect ( sendStub . secondCall ) . to . have . been . calledWith ( {
164158 method : 'DELETE' ,
165159 url : CLOUD_TASKS_URL_EMULATOR . concat ( '/' , 'mock-task' ) ,
166160 headers : EXPECTED_HEADERS_EMULATOR ,
167161 } ) ;
168162 } ) ;
169163
170- it ( 'should ignore empty string CLOUD_TASKS_EMULATOR_HOST' , async ( ) => {
171- process . env . CLOUD_TASKS_EMULATOR_HOST = '' ;
172- const emptyHostClient = new FunctionsApiClient ( app ) ;
173- delete process . env . CLOUD_TASKS_EMULATOR_HOST ;
174-
175- const stub = sinon
176- . stub ( HttpClient . prototype , 'send' )
177- . resolves ( utils . responseFrom ( { } , 200 ) ) ;
178- stubs . push ( stub ) ;
179-
180- await emptyHostClient . delete ( 'mock-task' , FUNCTION_NAME ) ;
181- expect ( stub ) . to . have . been . calledWith ( {
182- method : 'DELETE' ,
183- url : CLOUD_TASKS_URL . concat ( '/' , 'mock-task' ) ,
184- headers : EXPECTED_HEADERS ,
164+ for ( const hostVal of [ '' , ' ' ] ) {
165+ it ( `should ignore CLOUD_TASKS_EMULATOR_HOST when set to "${ hostVal } "` , async ( ) => {
166+ process . env . CLOUD_TASKS_EMULATOR_HOST = hostVal ;
167+ const emptyHostClient = new FunctionsApiClient ( app ) ;
168+ delete process . env . CLOUD_TASKS_EMULATOR_HOST ;
169+
170+ const stub = sinon
171+ . stub ( HttpClient . prototype , 'send' )
172+ . resolves ( utils . responseFrom ( { } , 200 ) ) ;
173+ stubs . push ( stub ) ;
174+
175+ await emptyHostClient . delete ( 'mock-task' , FUNCTION_NAME ) ;
176+ expect ( stub ) . to . have . been . calledWith ( {
177+ method : 'DELETE' ,
178+ url : CLOUD_TASKS_URL . concat ( '/' , 'mock-task' ) ,
179+ headers : EXPECTED_HEADERS ,
180+ } ) ;
185181 } ) ;
186- } ) ;
182+ }
187183 } ) ;
188184
189185 describe ( 'enqueue' , ( ) => {
0 commit comments