node-go/server/test/api.index.spec.js
2020-01-17 16:32:40 -08:00

41 lines
No EOL
1,015 B
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();
});
});
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;