Advertisement
Guest User

Untitled

a guest
Oct 26th, 2017
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. it( 'should return a session with proper request', function(){
  2.  
  3. const randomUser = new User({
  4. name: 'random',
  5. email: 'random@random.com',
  6. password: 'password2'
  7. });
  8.  
  9.  
  10. randomUser.save( (err) => {
  11. if (err){
  12. console.log( err.message);
  13. }
  14. });
  15.  
  16. const token = jwt.sign({
  17. _id: randomUser._id,
  18. }, JWT_SECRET, {
  19. expiresIn: 60 * 60
  20. });
  21.  
  22. console.log( 'token is: ', token );
  23. console.log( 'random user is: ', randomUser._id) ;
  24.  
  25. const practiceRequest = {
  26. operation: "+",
  27. number: "10", ///this will possible need to be sent as a number
  28. min: "1",
  29. max: "200"
  30. };
  31. return chai.request(app)
  32. .post('/api/session')
  33. .set('Authorization', 'Bearer ' + token)
  34. .send( practiceRequest )
  35. .then( (res) => {
  36. res.should.have.status(201);
  37. })
  38. });
  39.  
  40. });
  41. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement