|
1 | 1 | import fs = require("fs"); |
2 | 2 | import { join } from "path"; |
3 | | -import { createClient, getPort, success, successFn } from "./support/util"; |
| 3 | +import { |
| 4 | + createClient, |
| 5 | + createPartialDone, |
| 6 | + getPort, |
| 7 | + success, |
| 8 | + successFn, |
| 9 | +} from "./support/util"; |
4 | 10 | import { Server } from ".."; |
5 | 11 | import expect from "expect.js"; |
6 | 12 |
|
@@ -1039,5 +1045,30 @@ describe("socket", () => { |
1039 | 1045 | socket.emit("my-event", "123"); |
1040 | 1046 | }); |
1041 | 1047 | }); |
| 1048 | + |
| 1049 | + it("should disconnect all namespaces when calling disconnect(true)", (done) => { |
| 1050 | + const io = new Server(0); |
| 1051 | + io.of("/foo"); |
| 1052 | + io.of("/bar"); |
| 1053 | + |
| 1054 | + const socket1 = createClient(io, "/", { |
| 1055 | + transports: ["websocket"], |
| 1056 | + }); |
| 1057 | + const socket2 = createClient(io, "/foo"); |
| 1058 | + const socket3 = createClient(io, "/bar"); |
| 1059 | + |
| 1060 | + io.of("/bar").on("connection", (socket) => { |
| 1061 | + socket.disconnect(true); |
| 1062 | + }); |
| 1063 | + |
| 1064 | + const partialDone = createPartialDone( |
| 1065 | + 3, |
| 1066 | + successFn(done, io, socket1, socket2, socket3) |
| 1067 | + ); |
| 1068 | + |
| 1069 | + socket1.on("disconnect", partialDone); |
| 1070 | + socket2.on("disconnect", partialDone); |
| 1071 | + socket3.on("disconnect", partialDone); |
| 1072 | + }); |
1042 | 1073 | }); |
1043 | 1074 | }); |
0 commit comments