0

There is following signature of the function:

function hashPassword(password, callback){}

I want to call it within co generator function, so I try wrapping it with thunkify like this:

var checkPassword = thunk(user.checkPassword);
var isValid = yield checkPassword(userInfo.password);

As a result my unit test fails and stack trace doesn't show the reason:

at error (..\node_modules\supertest\lib\js:235:13)
at Test.assert (..\node_modules\supertes\test.js:166:19)
at assert (..\node_modules\supertest\lib.js:132:12)
at ..\node_modules\supertest\lib\test.js
at Test.Request.callback (..\node_modules\superagent\lib\node\index.js:738:30)
at Test.<anonymous> (..\node_modules\superagent\lib\node\index.js:135:10)
at Test.emit(events.js:107:17) at IncomingMessage.<anonymous> (..\node_es\supertest\node_modules\superagent\lib\node\index.js:915:12)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:907:16
at process._tickCallback (node.js:372:11)
Yevgen Safronov
  • 3,977
  • 1
  • 27
  • 38

1 Answers1

0

The solution would be to specify context for the function, because thunkify doesn't take care about it:

var checkPassword = thunk(user.checkPassword).bind(user);
Yevgen Safronov
  • 3,977
  • 1
  • 27
  • 38