Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"start": "node ./src/bin/www",
"devstart": "set DEBUG=dev && babel-watch ./src/bin/dev",
"build": "rm -rf dist && mkdir dist && babel src -s -d dist",
"test": " set NODE_ENV=test&& npm run reset-db&& nyc mocha -r @babel/register --recursive src/test/ --exit -timeout 10000",
"test": " set NODE_ENV=test&& npm run reset-db&& nyc mocha --timeout 2000 -r @babel/register --recursive src/test/ --exit",
"migrate": "./node_modules/.bin/sequelize db:migrate",
"drop-db": "./node_modules/.bin/sequelize db:migrate:undo:all",
"seeders": "./node_modules/.bin/sequelize db:seed:all",
Expand Down
255 changes: 132 additions & 123 deletions src/test/authTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Signup Error', () => {
.post(`${userEndPoint}signup`)
.send(user)
.end((err, res) => {
if (err) done(err);
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error');
Expand All @@ -37,6 +38,7 @@ describe('Signup Error', () => {
.post(`${userEndPoint}signup`)
.send(user)
.end((err, res) => {
if (err) done(err);
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error');
Expand All @@ -58,6 +60,7 @@ describe('Signup Error', () => {
.post(`${userEndPoint}signup`)
.send(user)
.end((err, res) => {
if (err) done(err);
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error');
Expand All @@ -66,132 +69,138 @@ describe('Signup Error', () => {
});
});

// describe(`POST ${userEndPoint}signup`, () => {
// it('Should create a new user', (done) => {
// const user = {
// email: 'temi@testmail.com',
// password: 'password',
// };
// chai.request(app)
// .post(`${userEndPoint}signup`)
// .send(user)
// .end((err, res) => {
// res.should.have.status(201);
// res.body.should.be.a('object');
// res.body.should.have.property('data');
// res.body.data.should.be.a('object');
// res.body.data.should.have.property('tokens');
// res.body.data.should.have.property('id');
// res.body.data.should.have.property('email');
// done();
// });
// });
// });
describe(`POST ${userEndPoint}signup`, () => {
it('Should create a new user', (done) => {
const user = {
email: 'temi@testmail.com',
password: 'password',
};
chai.request(app)
.post(`${userEndPoint}signup`)
.send(user)
.end((err, res) => {
if (err) done(err);
res.should.have.status(201);
res.body.should.be.a('object');
res.body.should.have.property('data');
res.body.data.should.be.a('object');
res.body.data.should.have.property('tokens');
res.body.data.should.have.property('id');
res.body.data.should.have.property('email');
done();
});
});
});

// describe('Signup Error', () => {
// it('Should return 409 if email already exists', (done) => {
// const user = {
// email: 'temi@testmail.com',
// password: 'password',
// };
// chai.request(app)
// .post(`${userEndPoint}signup`)
// .send(user)
// .end((err, res) => {
// res.should.have.status(409);
// res.body.should.be.a('object');
// res.body.should.have.property('error');
// done();
// });
// });
// });
describe('Signup Error', () => {
it('Should return 409 if email already exists', (done) => {
const user = {
email: 'temi@testmail.com',
password: 'password',
};
chai.request(app)
.post(`${userEndPoint}signup`)
.send(user)
.end((err, res) => {
if (err) done(err);
res.should.have.status(409);
res.body.should.be.a('object');
res.body.should.have.property('error');
done();
});
});
});

// describe('Signin Error', () => {
// it('Should deny access if wrong email is provided', (done) => {
// const login = {
// email: 'kcmykirl@gmail.com',
// password: 'pA55w0rd',
// };
// chai.request(app)
// .post(`${userEndPoint}signin`)
// .send(login)
// .end((err, res) => {
// res.should.have.status(404);
// res.body.should.be.a('object');
// res.body.should.have.property('error');
// done();
// });
// });
// });
describe('Signin Error', () => {
it('Should deny access if wrong email is provided', (done) => {
const login = {
email: 'kcmykirl@gmail.com',
password: 'pA55w0rd',
};
chai.request(app)
.post(`${userEndPoint}signin`)
.send(login)
.end((err, res) => {
if (err) done(err);
res.should.have.status(404);
res.body.should.be.a('object');
res.body.should.have.property('error');
done();
});
});
});

// describe('Signin Error', () => {
// it('Should deny access if wrong password is provided', (done) => {
// const login = {
// email: 'temi@testmail.com',
// password: 'passweod',
// };
// chai.request(app)
// .post(`${userEndPoint}signin`)
// .send(login)
// .end((err, res) => {
// res.should.have.status(401);
// res.body.should.be.a('object');
// res.body.should.have.property('error');
// done();
// });
// });
// });
describe('Signin Error', () => {
it('Should deny access if wrong password is provided', (done) => {
const login = {
email: 'temi@testmail.com',
password: 'passweod',
};
chai.request(app)
.post(`${userEndPoint}signin`)
.send(login)
.end((err, res) => {
res.should.have.status(401);
res.body.should.be.a('object');
res.body.should.have.property('error');
done();
});
});
});

// describe('Signin Errror', () => {
// it('Should return 400 if email is not provided', (done) => {
// const login = {
// password: 'password',
// };
// chai.request(app)
// .post(`${userEndPoint}signin`)
// .send(login)
// .end((err, res) => {
// res.should.have.status(400);
// res.body.should.be.a('object');
// res.body.should.have.property('error');
// done();
// });
// });
// });
describe('Signin Errror', () => {
it('Should return 400 if email is not provided', (done) => {
const login = {
password: 'password',
};
chai.request(app)
.post(`${userEndPoint}signin`)
.send(login)
.end((err, res) => {
if (err) done(err);
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error');
done();
});
});
});

// describe('Signin Error', () => {
// it('Should return 400 if password is ommited', (done) => {
// const login = {
// email: 'temi@testmail.com',
// };
// chai.request(app)
// .post(`${userEndPoint}signin`)
// .send(login)
// .end((err, res) => {
// res.should.have.status(400);
// res.body.should.be.a('object');
// res.body.should.have.property('error');
// done();
// });
// });
// });
describe('Signin Error', () => {
it('Should return 400 if password is ommited', (done) => {
const login = {
email: 'temi@testmail.com',
};
chai.request(app)
.post(`${userEndPoint}signin`)
.send(login)
.end((err, res) => {
if (err) done(err);
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error');
done();
});
});
});

// describe('User Login tests', () => {
// it('Should login a user successfully', (done) => {
// const login = {
// email: 'temi@testmail.com',
// password: 'password',
// };
// chai.request(app)
// .post(`${userEndPoint}signin`)
// .send(login)
// .end((err, res) => {
// res.should.have.status(200);
// res.body.should.be.a('object');
// res.body.should.have.property('data');
// res.body.data.should.be.a('object');
// res.body.data.should.have.property('tokens');
// done();
// });
// });
// });
describe('User Login tests', () => {
it('Should login a user successfully', (done) => {
const login = {
email: 'temi@testmail.com',
password: 'password',
};
chai.request(app)
.post(`${userEndPoint}signin`)
.send(login)
.end((err, res) => {
if (err) done(err);
res.should.have.status(200);
res.body.should.be.a('object');
res.body.should.have.property('data');
res.body.data.should.be.a('object');
res.body.data.should.have.property('tokens');
done();
});
});
});
Loading