22
33const test = require ( 'tape' ) ;
44const tryToCatch = require ( 'try-to-catch' ) ;
5+ const currify = require ( 'currify' ) ;
56
67const connect = require ( '../lib/connect' ) ;
78
@@ -33,7 +34,7 @@ test('fileop: options: authCheck not function', async (t) => {
3334} ) ;
3435
3536test ( 'fileop: options: authCheck: reject' , async ( t ) => {
36- const authCheck = ( username , password , accept , reject ) => {
37+ const authCheck = ( accept , reject ) => ( ) => {
3738 reject ( ) ;
3839 } ;
3940
@@ -49,7 +50,7 @@ test('fileop: options: authCheck: reject', async (t) => {
4950} ) ;
5051
5152test ( 'fileop: options: authCheck: accept' , async ( t ) => {
52- const authCheck = ( username , password , accept ) => {
53+ const authCheck = ( accept ) => ( ) => {
5354 accept ( ) ;
5455 } ;
5556
@@ -65,6 +66,23 @@ test('fileop: options: authCheck: accept', async (t) => {
6566 } ) ;
6667} ) ;
6768
69+ test ( 'fileop: options: authCheck: accept' , async ( t ) => {
70+ const user = 'bill' ;
71+ const pass = 'world' ;
72+
73+ const authCheck = currify ( ( accept , reject , username , password ) => {
74+ done ( ) ;
75+
76+ t . equal ( username , user , 'should pass username' ) ;
77+ t . equal ( password , pass , 'should pass password' ) ;
78+ t . end ( ) ;
79+ } ) ;
80+
81+ const { socket, done} = await connect ( { authCheck} ) ;
82+
83+ socket . emit ( 'auth' , user , pass ) ;
84+ } ) ;
85+
6886test ( 'fileop: listen: wrong operation' , async ( t ) => {
6987 const { socket, done} = await connect ( ) ;
7088
0 commit comments