Skip to content

Commit

Permalink
test: fix random test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Jan 4, 2021
1 parent f773b48 commit a0a3481
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/socket.io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe("socket.io", () => {
});

describe("close", () => {
it("should be able to close sio sending a srv", () => {
it("should be able to close sio sending a srv", (done) => {
const PORT = 54018;
const srv = createServer().listen(PORT);
const sio = new Server(srv);
Expand All @@ -282,19 +282,20 @@ describe("socket.io", () => {
const clientSocket = client(srv, { reconnection: false });

clientSocket.on("disconnect", () => {
expect(Object.keys(sio._nsps["/"].sockets).length).to.equal(0);
expect(sio.sockets.sockets.size).to.equal(0);
server.listen(PORT);
});

clientSocket.on("connect", () => {
expect(Object.keys(sio._nsps["/"].sockets).length).to.equal(1);
expect(sio.sockets.sockets.size).to.equal(1);
sio.close();
});

server.once("listening", () => {
// PORT should be free
server.close((error) => {
expect(error).to.be(undefined);
done();
});
});
});
Expand Down Expand Up @@ -856,7 +857,7 @@ describe("socket.io", () => {
srv.listen(() => {
const clientSocket = client(srv, {
reconnectionAttempts: 3,
reconnectionDelay: 10,
reconnectionDelay: 100,
});
clientSocket.on("connect", () => {
srv.close();
Expand Down

0 comments on commit a0a3481

Please sign in to comment.