Skip to content

Commit 878c764

Browse files
committed
test(NODE-4834): Split up tests more cleanly
1 parent 23755ca commit 878c764

File tree

1 file changed

+41
-17
lines changed

1 file changed

+41
-17
lines changed

test/unit/cmap/connection.test.ts

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -616,23 +616,6 @@ describe('new Connection()', function () {
616616
clock.restore();
617617
});
618618

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-
636619
context('when options.force == true', function () {
637620
it('calls steam.destroy', () => {
638621
connection.destroy({ force: true });
@@ -645,6 +628,26 @@ describe('new Connection()', function () {
645628
clock.tick(1);
646629
expect(driverSocket.end).to.not.have.been.called;
647630
});
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+
});
648651
});
649652

650653
context('when options.force == false', function () {
@@ -659,6 +662,27 @@ describe('new Connection()', function () {
659662
clock.tick(1);
660663
expect(driverSocket.destroy).to.not.have.been.called;
661664
});
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+
});
662686
});
663687
});
664688
});

0 commit comments

Comments
 (0)