@@ -408,6 +408,7 @@ describe('Server', () => {
408
408
( error : ServiceError , response : any ) => {
409
409
assert ( error ) ;
410
410
assert . strictEqual ( error . code , grpc . status . UNIMPLEMENTED ) ;
411
+ assert . match ( error . details , / d o e s n o t i m p l e m e n t t h e m e t h o d .* D i v / ) ;
411
412
done ( ) ;
412
413
}
413
414
) ;
@@ -417,6 +418,7 @@ describe('Server', () => {
417
418
const call = client . sum ( ( error : ServiceError , response : any ) => {
418
419
assert ( error ) ;
419
420
assert . strictEqual ( error . code , grpc . status . UNIMPLEMENTED ) ;
421
+ assert . match ( error . details , / d o e s n o t i m p l e m e n t t h e m e t h o d .* S u m / ) ;
420
422
done ( ) ;
421
423
} ) ;
422
424
@@ -433,6 +435,7 @@ describe('Server', () => {
433
435
call . on ( 'error' , ( err : ServiceError ) => {
434
436
assert ( err ) ;
435
437
assert . strictEqual ( err . code , grpc . status . UNIMPLEMENTED ) ;
438
+ assert . match ( err . details , / d o e s n o t i m p l e m e n t t h e m e t h o d .* F i b / ) ;
436
439
done ( ) ;
437
440
} ) ;
438
441
} ) ;
@@ -447,6 +450,93 @@ describe('Server', () => {
447
450
call . on ( 'error' , ( err : ServiceError ) => {
448
451
assert ( err ) ;
449
452
assert . strictEqual ( err . code , grpc . status . UNIMPLEMENTED ) ;
453
+ assert . match ( err . details , / d o e s n o t i m p l e m e n t t h e m e t h o d .* D i v M a n y / ) ;
454
+ done ( ) ;
455
+ } ) ;
456
+
457
+ call . end ( ) ;
458
+ } ) ;
459
+ } ) ;
460
+
461
+ describe ( 'Unregistered service' , ( ) => {
462
+ let server : Server ;
463
+ let client : ServiceClient ;
464
+
465
+ const mathProtoFile = path . join ( __dirname , 'fixtures' , 'math.proto' ) ;
466
+ const mathClient = ( loadProtoFile ( mathProtoFile ) . math as any ) . Math ;
467
+
468
+ before ( done => {
469
+ server = new Server ( ) ;
470
+ // Don't register a service at all
471
+ server . bindAsync (
472
+ 'localhost:0' ,
473
+ ServerCredentials . createInsecure ( ) ,
474
+ ( err , port ) => {
475
+ assert . ifError ( err ) ;
476
+ client = new mathClient (
477
+ `localhost:${ port } ` ,
478
+ grpc . credentials . createInsecure ( )
479
+ ) ;
480
+ server . start ( ) ;
481
+ done ( ) ;
482
+ }
483
+ ) ;
484
+ } ) ;
485
+
486
+ after ( done => {
487
+ client . close ( ) ;
488
+ server . tryShutdown ( done ) ;
489
+ } ) ;
490
+
491
+ it ( 'should respond to a unary call with UNIMPLEMENTED' , done => {
492
+ client . div (
493
+ { divisor : 4 , dividend : 3 } ,
494
+ ( error : ServiceError , response : any ) => {
495
+ assert ( error ) ;
496
+ assert . strictEqual ( error . code , grpc . status . UNIMPLEMENTED ) ;
497
+ assert . match ( error . details , / d o e s n o t i m p l e m e n t t h e m e t h o d .* D i v / ) ;
498
+ done ( ) ;
499
+ }
500
+ ) ;
501
+ } ) ;
502
+
503
+ it ( 'should respond to a client stream with UNIMPLEMENTED' , done => {
504
+ const call = client . sum ( ( error : ServiceError , response : any ) => {
505
+ assert ( error ) ;
506
+ assert . strictEqual ( error . code , grpc . status . UNIMPLEMENTED ) ;
507
+ assert . match ( error . details , / d o e s n o t i m p l e m e n t t h e m e t h o d .* S u m / ) ;
508
+ done ( ) ;
509
+ } ) ;
510
+
511
+ call . end ( ) ;
512
+ } ) ;
513
+
514
+ it ( 'should respond to a server stream with UNIMPLEMENTED' , done => {
515
+ const call = client . fib ( { limit : 5 } ) ;
516
+
517
+ call . on ( 'data' , ( value : any ) => {
518
+ assert . fail ( 'No messages expected' ) ;
519
+ } ) ;
520
+
521
+ call . on ( 'error' , ( err : ServiceError ) => {
522
+ assert ( err ) ;
523
+ assert . strictEqual ( err . code , grpc . status . UNIMPLEMENTED ) ;
524
+ assert . match ( err . details , / d o e s n o t i m p l e m e n t t h e m e t h o d .* F i b / ) ;
525
+ done ( ) ;
526
+ } ) ;
527
+ } ) ;
528
+
529
+ it ( 'should respond to a bidi call with UNIMPLEMENTED' , done => {
530
+ const call = client . divMany ( ) ;
531
+
532
+ call . on ( 'data' , ( value : any ) => {
533
+ assert . fail ( 'No messages expected' ) ;
534
+ } ) ;
535
+
536
+ call . on ( 'error' , ( err : ServiceError ) => {
537
+ assert ( err ) ;
538
+ assert . strictEqual ( err . code , grpc . status . UNIMPLEMENTED ) ;
539
+ assert . match ( err . details , / d o e s n o t i m p l e m e n t t h e m e t h o d .* D i v M a n y / ) ;
450
540
done ( ) ;
451
541
} ) ;
452
542
0 commit comments