javascript - how can i unit test passportjs with mocha? -


i test method using mocha , don't know start ? route :

 app.post('/signup', passport.authenticate('local-signup', {                 failureredirect: '/#/',                 failureflash: true             }),             function(req, res) {                 res.jsonp(req.user);             }); 

and here definition of service :

passport.use('local-signup', new localstrategy({             // default, local strategy uses username , password, override email             usernamefield: 'email',             passwordfield: 'password',             pseudofield: 'pseudo',              passreqtocallback: true // allows pass entire request callback         },         function(req, email, password, pseudo, done) {              // asynchronous             // user.findone wont fire unless data sent             process.nexttick(function() {                  // find user email same forms email                 // checking see if user trying login exists                 user.findone({                     'local.email': email                 }, function(err, user) {                     // if there errors, return error                     if (err)                         return done(err);                      // check see if theres user email                     if (user) {                         console.log('that email taken');                         //var newuser = new user();                         return done(404, null);                         // return done(null, false, req.flash('signupmessage', 'that email taken.'));                     } else {                          // if there no user email                         // create user                         console.log('creation new user');                         var newuser = new user();                         // set user's local credentials                         newuser.local.email = email;                         newuser.local.password = newuser.generatehash(password);                         newuser.local.pseudo = pseudo;                         console.log(pseudo);                         console.log(newuser.local);                         // save user                         console.log('going save in bdd');                         newuser.save(function(err) {                             if (err)                                 throw err;                             return done(null, newuser);                         });                     }                  });              });          })); 

i need know how test methode , how call it.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -