Skip to content

Commit

Permalink
test: add failing tests showing the issue in socketio#698
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanperret committed Feb 23, 2024
1 parent 0efa04b commit 260cd32
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2759,13 +2759,23 @@ describe("server", () => {
});
});

it("should execute in multipart packet", (done) => {
it("should execute in multipart packet (websocket)", (done) => {
const engine = listen((port) => {
const socket = new ClientSocket(`ws://localhost:${port}`);
const socket = new ClientSocket(`ws://localhost:${port}`, {
transports: ["websocket"],
});
let i = 0;
let j = 0;

engine.on("connection", (conn) => {
conn.send("d", (transport) => {
i++;
});

conn.send("c", (transport) => {
i++;
});

conn.send("b", (transport) => {
i++;
});
Expand Down
15 changes: 15 additions & 0 deletions test/webtransport.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,21 @@ describe("WebTransport", () => {
});
});

it("should invoke send callbacks (server to client)", (done) => {
setup({}, async ({ engine, h3Server, socket, reader }) => {
const messageCount = 4;
let receivedCallbacks = 0;

for (let i = 0; i < messageCount; i++) {
socket.send("hello", () => {
if (++receivedCallbacks === messageCount) {
success(engine, h3Server, done);
}
});
}
});
});

it("should send some binary data (client to server)", (done) => {
setup({}, async ({ engine, h3Server, socket, writer }) => {
socket.on("data", (data) => {
Expand Down

0 comments on commit 260cd32

Please sign in to comment.