Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit dfc2e43

Browse files
committed
network: make auth test not run assertions after the end
1 parent d5fb550 commit dfc2e43

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/network/websockets/server/auth.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ import { makeWsMock } from "./ws-mock";
44

55
test.cb("websocket server allows to read and write when auth allows", (t) => {
66
const ws = makeWsMock();
7+
let seenCorrectCanRead = false;
8+
let seenCorrectCanWrite = false;
9+
let seenCorrectParseToken = false;
710
runWebsocketServer({
811
auth: {
912
canRead: ({ auth, kind, id }) => {
10-
t.is(kind, "tasks");
11-
t.is(id, "1");
12-
t.is(auth, "john");
13+
if (kind === "tasks" && id === "1" && auth === "john")
14+
seenCorrectCanRead = true;
1315
return true;
1416
},
1517
canWrite: ({ auth, kind, id }) => {
16-
t.is(kind, "tasks");
17-
t.is(id, "1");
18-
t.is(auth, "john");
18+
if (kind === "tasks" && id === "1" && auth === "john")
19+
seenCorrectCanWrite = true;
1920
return true;
2021
},
2122
parseToken: async (token) => {
22-
t.is(token, "t1");
23+
if (token === "t1") seenCorrectParseToken = true;
2324
return "john";
2425
},
2526
},
@@ -31,6 +32,9 @@ test.cb("websocket server allows to read and write when auth allows", (t) => {
3132
});
3233
const client = ws.client((msg) => {
3334
if (msg.action === "pushResult" && msg.newRevision === "2") {
35+
t.true(seenCorrectCanRead);
36+
t.true(seenCorrectCanWrite);
37+
t.true(seenCorrectParseToken);
3438
t.end();
3539
}
3640
});

0 commit comments

Comments
 (0)