I've got a function which returns next(); as a function to allow next route to be called and it's used for checking the token as an interceptor and allows function to go through.
The problem I have now is that I want to test this particular function and I don't have next route it's just that one so when I use some API testing tool like Hippie and make a request it hangs and does nothing until timed out.
So the test call I have is like below with Hippie:
hippie(server)
.header('token', token)
.json()
.put('/token')
.send(tokenRequest)
.end(function(err, res, body) {
if (err) {
throw err;
}
done();
});
Basically token endpoint is linking to token interceptor and that returns next();
How do I make this into testable state?