@@ -98,7 +98,6 @@ describe('Firebase Functions > Call', () => {
9898 { message : string ; code : number ; long : number }
9999 > ( functions , 'dataTest' ) ;
100100 try {
101-
102101 const result = await func ( data ) ;
103102
104103 expect ( result . data ) . to . deep . equal ( {
@@ -329,9 +328,15 @@ describe('Firebase Functions > Stream', () => {
329328 it ( 'successfully streams data and resolves final result' , async ( ) => {
330329 const mockResponse = new ReadableStream ( {
331330 start ( controller ) {
332- controller . enqueue ( new TextEncoder ( ) . encode ( 'data: {"message":"Hello"}\n' ) ) ;
333- controller . enqueue ( new TextEncoder ( ) . encode ( 'data: {"message":"World"}\n' ) ) ;
334- controller . enqueue ( new TextEncoder ( ) . encode ( 'data: {"result":"Final Result"}\n' ) ) ;
331+ controller . enqueue (
332+ new TextEncoder ( ) . encode ( 'data: {"message":"Hello"}\n' )
333+ ) ;
334+ controller . enqueue (
335+ new TextEncoder ( ) . encode ( 'data: {"message":"World"}\n' )
336+ ) ;
337+ controller . enqueue (
338+ new TextEncoder ( ) . encode ( 'data: {"result":"Final Result"}\n' )
339+ ) ;
335340 controller . close ( ) ;
336341 }
337342 } ) ;
@@ -340,10 +345,13 @@ describe('Firebase Functions > Stream', () => {
340345 body : mockResponse ,
341346 headers : new Headers ( { 'Content-Type' : 'text/event-stream' } ) ,
342347 status : 200 ,
343- statusText : 'OK' ,
348+ statusText : 'OK'
344349 } as Response ) ;
345350
346- const func = httpsCallable < Record < string , any > , string , string > ( functions , 'streamTest' ) ;
351+ const func = httpsCallable < Record < string , any > , string , string > (
352+ functions ,
353+ 'streamTest'
354+ ) ;
347355 const streamResult = await func . stream ( { } ) ;
348356
349357 const messages : string [ ] = [ ] ;
@@ -358,8 +366,14 @@ describe('Firebase Functions > Stream', () => {
358366 it ( 'successfully process request chunk with multiple events' , async ( ) => {
359367 const mockResponse = new ReadableStream ( {
360368 start ( controller ) {
361- controller . enqueue ( new TextEncoder ( ) . encode ( 'data: {"message":"Hello"}\n\ndata: {"message":"World"}\n' ) ) ;
362- controller . enqueue ( new TextEncoder ( ) . encode ( 'data: {"result":"Final Result"}\n' ) ) ;
369+ controller . enqueue (
370+ new TextEncoder ( ) . encode (
371+ 'data: {"message":"Hello"}\n\ndata: {"message":"World"}\n'
372+ )
373+ ) ;
374+ controller . enqueue (
375+ new TextEncoder ( ) . encode ( 'data: {"result":"Final Result"}\n' )
376+ ) ;
363377 controller . close ( ) ;
364378 }
365379 } ) ;
@@ -368,10 +382,13 @@ describe('Firebase Functions > Stream', () => {
368382 body : mockResponse ,
369383 headers : new Headers ( { 'Content-Type' : 'text/event-stream' } ) ,
370384 status : 200 ,
371- statusText : 'OK' ,
385+ statusText : 'OK'
372386 } as Response ) ;
373387
374- const func = httpsCallable < Record < string , any > , string , string > ( functions , 'streamTest' ) ;
388+ const func = httpsCallable < Record < string , any > , string , string > (
389+ functions ,
390+ 'streamTest'
391+ ) ;
375392 const streamResult = await func . stream ( { } ) ;
376393
377394 const messages : string [ ] = [ ] ;
@@ -386,7 +403,10 @@ describe('Firebase Functions > Stream', () => {
386403 it ( 'handles network errors' , async ( ) => {
387404 mockFetch . rejects ( new Error ( 'Network error' ) ) ;
388405
389- const func = httpsCallable < Record < string , any > , string , string > ( functions , 'errTest' ) ;
406+ const func = httpsCallable < Record < string , any > , string , string > (
407+ functions ,
408+ 'errTest'
409+ ) ;
390410 const streamResult = await func . stream ( { } ) ;
391411
392412 let errorThrown = false ;
@@ -396,16 +416,22 @@ describe('Firebase Functions > Stream', () => {
396416 }
397417 } catch ( error : unknown ) {
398418 errorThrown = true ;
399- expect ( ( error as FunctionsError ) . code ) . to . equal ( `${ FUNCTIONS_TYPE } /internal` ) ;
419+ expect ( ( error as FunctionsError ) . code ) . to . equal (
420+ `${ FUNCTIONS_TYPE } /internal`
421+ ) ;
400422 }
401423 expect ( errorThrown ) . to . be . true ;
402- await expectError ( streamResult . data , " internal" , " internal" ) ;
424+ await expectError ( streamResult . data , ' internal' , ' internal' ) ;
403425 } ) ;
404426
405427 it ( 'handles server-side errors' , async ( ) => {
406428 const mockResponse = new ReadableStream ( {
407429 start ( controller ) {
408- controller . enqueue ( new TextEncoder ( ) . encode ( 'data: {"error":{"status":"INVALID_ARGUMENT","message":"Invalid input"}}\n' ) ) ;
430+ controller . enqueue (
431+ new TextEncoder ( ) . encode (
432+ 'data: {"error":{"status":"INVALID_ARGUMENT","message":"Invalid input"}}\n'
433+ )
434+ ) ;
409435 controller . close ( ) ;
410436 }
411437 } ) ;
@@ -414,10 +440,13 @@ describe('Firebase Functions > Stream', () => {
414440 body : mockResponse ,
415441 headers : new Headers ( { 'Content-Type' : 'text/event-stream' } ) ,
416442 status : 200 ,
417- statusText : 'OK' ,
443+ statusText : 'OK'
418444 } as Response ) ;
419445
420- const func = httpsCallable < Record < string , any > , string , string > ( functions , 'stream' ) ;
446+ const func = httpsCallable < Record < string , any > , string , string > (
447+ functions ,
448+ 'stream'
449+ ) ;
421450 const streamResult = await func . stream ( { } ) ;
422451
423452 let errorThrown = false ;
@@ -427,12 +456,14 @@ describe('Firebase Functions > Stream', () => {
427456 }
428457 } catch ( error ) {
429458 errorThrown = true ;
430- expect ( ( error as FunctionsError ) . code ) . to . equal ( `${ FUNCTIONS_TYPE } /invalid-argument` ) ;
459+ expect ( ( error as FunctionsError ) . code ) . to . equal (
460+ `${ FUNCTIONS_TYPE } /invalid-argument`
461+ ) ;
431462 expect ( ( error as FunctionsError ) . message ) . to . equal ( 'Invalid input' ) ;
432463 }
433464
434465 expect ( errorThrown ) . to . be . true ;
435- await expectError ( streamResult . data , " invalid-argument" , " Invalid input" ) ;
466+ await expectError ( streamResult . data , ' invalid-argument' , ' Invalid input' ) ;
436467 } ) ;
437468
438469 it ( 'includes authentication and app check tokens in request headers' , async ( ) => {
@@ -461,12 +492,20 @@ describe('Firebase Functions > Stream', () => {
461492 )
462493 ) ;
463494
464- const functions = createTestService ( app , region , authProvider , undefined , appCheckProvider ) ;
495+ const functions = createTestService (
496+ app ,
497+ region ,
498+ authProvider ,
499+ undefined ,
500+ appCheckProvider
501+ ) ;
465502 const mockFetch = sinon . stub ( functions , 'fetchImpl' as any ) ;
466503
467504 const mockResponse = new ReadableStream ( {
468505 start ( controller ) {
469- controller . enqueue ( new TextEncoder ( ) . encode ( 'data: {"result":"Success"}\n' ) ) ;
506+ controller . enqueue (
507+ new TextEncoder ( ) . encode ( 'data: {"result":"Success"}\n' )
508+ ) ;
470509 controller . close ( ) ;
471510 }
472511 } ) ;
@@ -475,10 +514,13 @@ describe('Firebase Functions > Stream', () => {
475514 body : mockResponse ,
476515 headers : new Headers ( { 'Content-Type' : 'text/event-stream' } ) ,
477516 status : 200 ,
478- statusText : 'OK' ,
517+ statusText : 'OK'
479518 } as Response ) ;
480519
481- const func = httpsCallable < Record < string , any > , string , string > ( functions , 'stream' ) ;
520+ const func = httpsCallable < Record < string , any > , string , string > (
521+ functions ,
522+ 'stream'
523+ ) ;
482524 await func . stream ( { } ) ;
483525
484526 expect ( mockFetch . calledOnce ) . to . be . true ;
@@ -501,7 +543,10 @@ describe('Firebase Functions > Stream', () => {
501543 } ) ;
502544 mockFetch . returns ( fetchPromise ) ;
503545
504- const func = httpsCallable < Record < string , any > , string , string > ( functions , 'streamTest' ) ;
546+ const func = httpsCallable < Record < string , any > , string , string > (
547+ functions ,
548+ 'streamTest'
549+ ) ;
505550 const streamPromise = func . stream ( { } , { signal : controller . signal } ) ;
506551
507552 controller . abort ( ) ;
@@ -521,23 +566,31 @@ describe('Firebase Functions > Stream', () => {
521566 }
522567 } catch ( error ) {
523568 errorThrown = true ;
524- expect ( ( error as FunctionsError ) . code ) . to . equal ( `${ FUNCTIONS_TYPE } /cancelled` ) ;
569+ expect ( ( error as FunctionsError ) . code ) . to . equal (
570+ `${ FUNCTIONS_TYPE } /cancelled`
571+ ) ;
525572 }
526573 expect ( errorThrown ) . to . be . true ;
527- await expectError ( streamResult . data , " cancelled" , " Request was cancelled." ) ;
574+ await expectError ( streamResult . data , ' cancelled' , ' Request was cancelled.' ) ;
528575 } ) ;
529576
530577 it ( 'aborts during streaming' , async ( ) => {
531578 const controller = new AbortController ( ) ;
532579
533580 const mockResponse = new ReadableStream ( {
534581 async start ( controller ) {
535- controller . enqueue ( new TextEncoder ( ) . encode ( 'data: {"message":"First"}\n' ) ) ;
582+ controller . enqueue (
583+ new TextEncoder ( ) . encode ( 'data: {"message":"First"}\n' )
584+ ) ;
536585 // Add delay to simulate network latency
537586 await new Promise ( resolve => setTimeout ( resolve , 50 ) ) ;
538- controller . enqueue ( new TextEncoder ( ) . encode ( 'data: {"message":"Second"}\n' ) ) ;
587+ controller . enqueue (
588+ new TextEncoder ( ) . encode ( 'data: {"message":"Second"}\n' )
589+ ) ;
539590 await new Promise ( resolve => setTimeout ( resolve , 50 ) ) ;
540- controller . enqueue ( new TextEncoder ( ) . encode ( 'data: {"result":"Final"}\n' ) ) ;
591+ controller . enqueue (
592+ new TextEncoder ( ) . encode ( 'data: {"result":"Final"}\n' )
593+ ) ;
541594 controller . close ( ) ;
542595 }
543596 } ) ;
@@ -546,10 +599,13 @@ describe('Firebase Functions > Stream', () => {
546599 body : mockResponse ,
547600 headers : new Headers ( { 'Content-Type' : 'text/event-stream' } ) ,
548601 status : 200 ,
549- statusText : 'OK' ,
602+ statusText : 'OK'
550603 } as Response ) ;
551604
552- const func = httpsCallable < Record < string , any > , string , string > ( functions , 'streamTest' ) ;
605+ const func = httpsCallable < Record < string , any > , string , string > (
606+ functions ,
607+ 'streamTest'
608+ ) ;
553609 const streamResult = await func . stream ( { } , { signal : controller . signal } ) ;
554610
555611 const messages : string [ ] = [ ] ;
@@ -563,10 +619,12 @@ describe('Firebase Functions > Stream', () => {
563619 }
564620 throw new Error ( 'Stream should have been aborted' ) ;
565621 } catch ( error ) {
566- expect ( ( error as FunctionsError ) . code ) . to . equal ( `${ FUNCTIONS_TYPE } /cancelled` ) ;
622+ expect ( ( error as FunctionsError ) . code ) . to . equal (
623+ `${ FUNCTIONS_TYPE } /cancelled`
624+ ) ;
567625 }
568626 expect ( messages ) . to . deep . equal ( [ 'First' ] ) ;
569- await expectError ( streamResult . data , " cancelled" , " Request was cancelled." ) ;
627+ await expectError ( streamResult . data , ' cancelled' , ' Request was cancelled.' ) ;
570628 } ) ;
571629
572630 it ( 'fails immediately with pre-aborted signal' , async ( ) => {
@@ -578,7 +636,10 @@ describe('Firebase Functions > Stream', () => {
578636 }
579637 return Promise . resolve ( new Response ( ) ) ;
580638 } ) ;
581- const func = httpsCallable < Record < string , any > , string , string > ( functions , 'streamTest' ) ;
639+ const func = httpsCallable < Record < string , any > , string , string > (
640+ functions ,
641+ 'streamTest'
642+ ) ;
582643 const streamResult = await func . stream ( { } , { signal : AbortSignal . abort ( ) } ) ;
583644
584645 let errorThrown = false ;
@@ -588,10 +649,12 @@ describe('Firebase Functions > Stream', () => {
588649 }
589650 } catch ( error ) {
590651 errorThrown = true ;
591- expect ( ( error as FunctionsError ) . code ) . to . equal ( `${ FUNCTIONS_TYPE } /cancelled` ) ;
652+ expect ( ( error as FunctionsError ) . code ) . to . equal (
653+ `${ FUNCTIONS_TYPE } /cancelled`
654+ ) ;
592655 }
593656 expect ( errorThrown ) . to . be . true ;
594- await expectError ( streamResult . data , " cancelled" , " Request was cancelled." ) ;
657+ await expectError ( streamResult . data , ' cancelled' , ' Request was cancelled.' ) ;
595658 } ) ;
596659
597660 it ( 'properly handles AbortSignal.timeout()' , async ( ) => {
@@ -612,7 +675,10 @@ describe('Firebase Functions > Stream', () => {
612675 return new Response ( ) ;
613676 } ) ;
614677
615- const func = httpsCallable < Record < string , any > , string , string > ( functions , 'streamTest' ) ;
678+ const func = httpsCallable < Record < string , any > , string , string > (
679+ functions ,
680+ 'streamTest'
681+ ) ;
616682 const streamResult = await func . stream ( { } , { signal } ) ;
617683
618684 try {
@@ -621,8 +687,10 @@ describe('Firebase Functions > Stream', () => {
621687 }
622688 throw new Error ( 'Stream should have timed out' ) ;
623689 } catch ( error ) {
624- expect ( ( error as FunctionsError ) . code ) . to . equal ( `${ FUNCTIONS_TYPE } /cancelled` ) ;
690+ expect ( ( error as FunctionsError ) . code ) . to . equal (
691+ `${ FUNCTIONS_TYPE } /cancelled`
692+ ) ;
625693 }
626- await expectError ( streamResult . data , " cancelled" , " Request was cancelled." ) ;
694+ await expectError ( streamResult . data , ' cancelled' , ' Request was cancelled.' ) ;
627695 } ) ;
628696} ) ;
0 commit comments