node-go/server/test/api.index.spec.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-01-18 00:32:40 +00:00
const apiIndexSpec = (chai, knex, server) => {
const newUserFormData = {
'username':'newUser',
'password':'password',
'confirmPassword':'password',
'email':'user@example.com'
}
it('home should return 200 status', done => {
chai.request(server)
.get('/api/v1')
.end((err,res)=> {
if(err) done(err);
res.should.status(200);
done();
});
});
2020-01-18 22:15:44 +00:00
// TODO why is ChaiHTTP not saving cookie('token') with agent?
// it('home should return user object if req contains verified JWT', done => {
// const agent = chai.request.agent(server);
// agent
// .post('/auth/signup')
// .type('form')
// .send(newUserFormData)
// .end((err, res) => {
// if (err) done(err);
// agent
// .get('/api/v1')
// .end((err,res)=> {
// if(err) done(err);
// res.should.have.property('body').property('username').equal('newUser');
// res.should.have.property('body').property('email').equal('user@example.com');
// res.should.status(200);
// done();
// });
// });
// })
2020-01-18 00:32:40 +00:00
}
module.exports = apiIndexSpec;