node-go/packages/play-node-go/server/test/api.index.spec.js
2020-02-05 16:44:33 -08:00

42 lines
No EOL
1.1 KiB
JavaScript

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();
});
});
// 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();
// });
// });
// })
}
module.exports = apiIndexSpec;