/join <room>

This commit is contained in:
Schluffe
2026-09-17 00:43:38 +02:00
parent 852a721c04
commit 6e867e33b1
2 changed files with 61 additions and 28 deletions
+21 -21
View File
@@ -47,41 +47,41 @@ function flush(): Promise<void> {
}
Deno.test(
"broadcasts a message on connect to all clients",
"welcome all clients on open",
setup(async () => {
const [s1, m1] = await connect(href);
const [s2, m2] = await connect(href);
await flush();
assertEquals(m1, ["1 has joined!", "2 has joined!"]);
assertEquals(m2, ["2 has joined!"]);
assertEquals(m1, ["Welcome 1, type /join <room>."]);
assertEquals(m2, ["Welcome 2, type /join <room>."]);
await close(s2);
await close(s1);
}),
);
Deno.test(
"removes a client from broadcast after it disconnects",
setup(async () => {
const [s1, m1] = await connect(href);
const [s2, m2] = await connect(href);
const [s3, m3] = await connect(href);
// Deno.test(
// "removes a client from broadcast after it disconnects",
// setup(async () => {
// const [s1, m1] = await connect(href);
// const [s2, m2] = await connect(href);
// const [s3, m3] = await connect(href);
await flush();
// await flush();
m1.length = 0;
m2.length = 0;
m3.length = 0;
// m1.length = 0;
// m2.length = 0;
// m3.length = 0;
await close(s3);
// await close(s3);
assertEquals(m1, ["3 has left!"]);
assertEquals(m2, ["3 has left!"]);
assertEquals(m3, []);
// assertEquals(m1, ["3 has left!"]);
// assertEquals(m2, ["3 has left!"]);
// assertEquals(m3, []);
await close(s2);
await close(s1);
}),
);
// await close(s2);
// await close(s1);
// }),
// );