This repository was archived by the owner on Dec 14, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
src/network/websockets/server Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -4,22 +4,23 @@ import { makeWsMock } from "./ws-mock";
4
4
5
5
test . cb ( "websocket server allows to read and write when auth allows" , ( t ) => {
6
6
const ws = makeWsMock ( ) ;
7
+ let seenCorrectCanRead = false ;
8
+ let seenCorrectCanWrite = false ;
9
+ let seenCorrectParseToken = false ;
7
10
runWebsocketServer ( {
8
11
auth : {
9
12
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 ;
13
15
return true ;
14
16
} ,
15
17
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 ;
19
20
return true ;
20
21
} ,
21
22
parseToken : async ( token ) => {
22
- t . is ( token , "t1" ) ;
23
+ if ( token === "t1" ) seenCorrectParseToken = true ;
23
24
return "john" ;
24
25
} ,
25
26
} ,
@@ -31,6 +32,9 @@ test.cb("websocket server allows to read and write when auth allows", (t) => {
31
32
} ) ;
32
33
const client = ws . client ( ( msg ) => {
33
34
if ( msg . action === "pushResult" && msg . newRevision === "2" ) {
35
+ t . true ( seenCorrectCanRead ) ;
36
+ t . true ( seenCorrectCanWrite ) ;
37
+ t . true ( seenCorrectParseToken ) ;
34
38
t . end ( ) ;
35
39
}
36
40
} ) ;
You can’t perform that action at this time.
0 commit comments