2020-01-15 21:52:01 +00:00
|
|
|
const authSignupSpec = (chai, knex, server) => {
|
|
|
|
const newUserFormData = {
|
|
|
|
'username':'newUser',
|
|
|
|
'password':'password',
|
2020-01-16 04:04:55 +00:00
|
|
|
'confirmPassword':'password',
|
2020-01-15 21:52:01 +00:00
|
|
|
'email':'user@example.com'
|
|
|
|
}
|
|
|
|
const loginFormData = {
|
|
|
|
'username':'newUser',
|
|
|
|
'password':'password'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-11 06:05:33 +00:00
|
|
|
// it('post to /login with non-registered user should return status 401 with bad creds err', done => {
|
|
|
|
// chai.request(server)
|
|
|
|
// .post('/auth/login')
|
|
|
|
// .type('form')
|
|
|
|
// .send(newUserFormData)
|
|
|
|
// .end((err, res) => {
|
|
|
|
// if (err) done(err);
|
|
|
|
// res.should.status(401);
|
|
|
|
// res.body.errors.should.equal('bad credentials');
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// })
|
2020-01-15 21:52:01 +00:00
|
|
|
|
2020-02-11 06:05:33 +00:00
|
|
|
// it('post to /login with non-registered user should return status 401 with bad creds err', done => {
|
|
|
|
// chai.request(server)
|
|
|
|
// .post('/auth/login')
|
|
|
|
// .type('form')
|
|
|
|
// .send(newUserFormData)
|
|
|
|
// .end((err, res) => {
|
|
|
|
// if (err) done(err);
|
|
|
|
// res.should.status(401);
|
|
|
|
// res.body.errors.should.equal('bad credentials');
|
|
|
|
// done();
|
|
|
|
// })
|
|
|
|
// })
|
2020-01-15 21:52:01 +00:00
|
|
|
|
2020-02-11 06:05:33 +00:00
|
|
|
// it('post to /login with registered user should return cookie', done => {
|
|
|
|
// chai.request(server)
|
|
|
|
// .post('/auth/signup')
|
|
|
|
// .type('form')
|
|
|
|
// .send(newUserFormData)
|
|
|
|
// .end((err, res) => {
|
|
|
|
// if (err) done(err);
|
2020-01-15 21:52:01 +00:00
|
|
|
|
2020-02-11 06:05:33 +00:00
|
|
|
// chai.request(server)
|
|
|
|
// .post('/auth/login')
|
|
|
|
// .type('form')
|
|
|
|
// .send(loginFormData)
|
|
|
|
// .end((err, res) => {
|
|
|
|
// if(err) done(err);
|
|
|
|
// res.should.status(200);
|
|
|
|
// res.should.cookie('token');
|
|
|
|
// done();
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
// })
|
2020-01-15 21:52:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
module.exports = authSignupSpec;
|