Guest User

Untitled

a guest
Jul 16th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. registration(req, res) {
  2. if (!req.user) return res.status(401).send('Registration failed');
  3.  
  4. const { user } = req;
  5. return res.status(201).json({ user });
  6. },
  7.  
  8. const { expect } = require('chai');
  9. const sinon = require('sinon');
  10. const authController = require(...);
  11.  
  12. describe('authController', () => {
  13. const USER = {
  14. email: 'test@test.com',
  15. password: 'Test12345',
  16. confirm: 'Test12345',
  17. username: 'Test',
  18. };
  19.  
  20. it('it should send user data with email: test@test.com', () => {
  21. const req = { user: USER };
  22. const res = {
  23. status: sinon.stub().returnsThis(),
  24. json: sinon.spy(),
  25. };
  26.  
  27. console.log('RES: ', res); // об этом чуть ниже
  28. authController.registration(req, res);
  29. expect(res.json).to.equal(USER);
  30. });
  31.  
  32. expect(res.json.calledWith(USER)).to.equal(true);
Add Comment
Please, Sign In to add comment