@@ -2,6 +2,7 @@ import { Server, Socket } from "..";
|
2 | 2 | import expect from "expect.js";
|
3 | 3 | import { waitFor, eioHandshake, eioPush, eioPoll } from "./support/util";
|
4 | 4 | import { createServer, Server as HttpServer } from "http";
|
| 5 | +import { Adapter } from "socket.io-adapter"; |
5 | 6 |
|
6 | 7 | async function init(httpServer: HttpServer, io: Server) {
|
7 | 8 | // Engine.IO handshake
|
@@ -215,4 +216,32 @@ describe("connection state recovery", () => {
|
215 | 216 |
|
216 | 217 | io.close();
|
217 | 218 | });
|
| 219 | + |
| 220 | +it("should not call adapter#persistSession or adapter#restoreSession if disabled", async () => { |
| 221 | +const httpServer = createServer().listen(0); |
| 222 | + |
| 223 | +class DummyAdapter extends Adapter { |
| 224 | +override persistSession(session) { |
| 225 | +expect.fail(); |
| 226 | +} |
| 227 | + |
| 228 | +override restoreSession(pid, offset) { |
| 229 | +expect.fail(); |
| 230 | +return Promise.reject("should not happen"); |
| 231 | +} |
| 232 | +} |
| 233 | + |
| 234 | +const io = new Server(httpServer, { |
| 235 | +adapter: DummyAdapter, |
| 236 | +}); |
| 237 | + |
| 238 | +// Engine.IO handshake |
| 239 | +const sid = await eioHandshake(httpServer); |
| 240 | + |
| 241 | +await eioPush(httpServer, sid, '40{"pid":"foo","offset":"bar"}'); |
| 242 | +await eioPoll(httpServer, sid); |
| 243 | +await eioPush(httpServer, sid, "1"); |
| 244 | + |
| 245 | +io.close(); |
| 246 | +}); |
218 | 247 | });
|
0 commit comments