Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- process.env.NODE_ENV = 'test';
- //Require the dev-dependencies
- const chai = require('chai');
- const chaiHttp = require('chai-http');
- const server = require('../bin/www');
- const helper = require('./helper');
- const expect = chai.expect;
- const { reset, createUser } = helper;
- chai.use(chaiHttp);
- describe('Users routes', function() {
- beforeEach(reset);
- describe('/POST authenticate', function() {
- it('it should return 401 when user does not exist', async function() {
- return chai.request(server)
- .post('/users/authenticate')
- .send({
- username: 'aaa',
- password: '1234a'
- })
- .then((res) => {
- expect(res).to.have.status(401);
- })
- });
- it('it should send User authentication data and return success when user exists', async function() {
- await createUser();
- return chai.request(server)
- .post('/users/authenticate')
- .send({
- username: 'aaa',
- password: '1234a'
- })
- .then(function(res) {
- expect(res.status).to.be.eq(200);
- expect(res.body).to.be.a('object');
- expect(res.body).to.have.property('success');
- expect(res.body).to.have.property('token');
- });
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement