@@ -616,23 +616,6 @@ describe('new Connection()', function () {
616
616
clock . restore ( ) ;
617
617
} ) ;
618
618
619
- it ( 'ends the tcp socket and destroys the messageStream' , ( ) => {
620
- connection . destroy ( { force : false } ) ;
621
- clock . tick ( 1 ) ;
622
- expect ( messageStream . destroy ) . to . have . been . calledOnce ;
623
- expect ( driverSocket . end ) . to . have . been . calledOnce ;
624
- } ) ;
625
-
626
- it ( 'calls stream.end exactly once when destroy is called multiple times' , ( ) => {
627
- connection . destroy ( { force : false } ) ;
628
- connection . destroy ( { force : false } ) ;
629
- connection . destroy ( { force : false } ) ;
630
- connection . destroy ( { force : false } ) ;
631
- clock . tick ( 1 ) ;
632
- expect ( driverSocket . destroy ) . to . not . have . been . called ;
633
- expect ( driverSocket . end ) . to . have . been . calledOnce ;
634
- } ) ;
635
-
636
619
context ( 'when options.force == true' , function ( ) {
637
620
it ( 'calls steam.destroy' , ( ) => {
638
621
connection . destroy ( { force : true } ) ;
@@ -645,6 +628,26 @@ describe('new Connection()', function () {
645
628
clock . tick ( 1 ) ;
646
629
expect ( driverSocket . end ) . to . not . have . been . called ;
647
630
} ) ;
631
+
632
+ it ( 'destroys the tcp socket' , ( ) => {
633
+ connection . destroy ( { force : true } ) ;
634
+ clock . tick ( 1 ) ;
635
+ expect ( driverSocket . destroy ) . to . have . been . calledOnce ;
636
+ } ) ;
637
+
638
+ it ( 'destroys the messageStream' , ( ) => {
639
+ connection . destroy ( { force : true } ) ;
640
+ clock . tick ( 1 ) ;
641
+ expect ( messageStream . destroy ) . to . have . been . calledOnce ;
642
+ } ) ;
643
+
644
+ it ( 'calls stream.destroy whenever destroy is called ' , ( ) => {
645
+ connection . destroy ( { force : true } ) ;
646
+ connection . destroy ( { force : true } ) ;
647
+ connection . destroy ( { force : true } ) ;
648
+ clock . tick ( 1 ) ;
649
+ expect ( driverSocket . destroy ) . to . have . been . calledThrice ;
650
+ } ) ;
648
651
} ) ;
649
652
650
653
context ( 'when options.force == false' , function ( ) {
@@ -659,6 +662,27 @@ describe('new Connection()', function () {
659
662
clock . tick ( 1 ) ;
660
663
expect ( driverSocket . destroy ) . to . not . have . been . called ;
661
664
} ) ;
665
+
666
+ it ( 'ends the tcp socket' , ( ) => {
667
+ connection . destroy ( { force : false } ) ;
668
+ clock . tick ( 1 ) ;
669
+ expect ( driverSocket . end ) . to . have . been . calledOnce ;
670
+ } ) ;
671
+
672
+ it ( 'destroys the messageStream' , ( ) => {
673
+ connection . destroy ( { force : false } ) ;
674
+ clock . tick ( 1 ) ;
675
+ expect ( messageStream . destroy ) . to . have . been . calledOnce ;
676
+ } ) ;
677
+
678
+ it ( 'calls stream.end exactly once when destroy is called multiple times' , ( ) => {
679
+ connection . destroy ( { force : false } ) ;
680
+ connection . destroy ( { force : false } ) ;
681
+ connection . destroy ( { force : false } ) ;
682
+ connection . destroy ( { force : false } ) ;
683
+ clock . tick ( 1 ) ;
684
+ expect ( driverSocket . end ) . to . have . been . calledOnce ;
685
+ } ) ;
662
686
} ) ;
663
687
} ) ;
664
688
} ) ;
0 commit comments