Skip to content

Commit

Permalink
feat(auth-login): write more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilome committed Oct 1, 2018
1 parent e265671 commit 58ecd91
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/routes/auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('POST /auth/login', () => {
});
});

it('should not sign user in if invalid email or password is provided', (done) => {
it('should not sign user in if non-existent email is provided', (done) => {
chai.request(app)
.post('/api/v1/auth/login')
.send(seedData.users.invalidUser)
Expand All @@ -141,6 +141,19 @@ describe('POST /auth/login', () => {
});
});

it('should not sign user in if invalid password is provided', (done) => {
chai.request(app)
.post('/api/v1/auth/login')
.send(seedData.users.validUserInvalidPass)
.end((err, res) => {
if (err) done(err);

res.status.should.eql(400);
res.body.should.not.have.keys(['auth_token']);
done();
});
});

it('should not sign in user with improper input format', (done) => {
chai.request(app)
.post('/api/v1/auth/login')
Expand Down
4 changes: 4 additions & 0 deletions tests/seed/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const seedData = {
password: 'pixel2user',
confirmPassword: 'pixel2user',
},
validUserInvalidPass: {
email: 'daniel@james.com',
password: 'thisiswrong',
},
invalidUser: {
name: 'four-O-four',
email: 'no@email.address',
Expand Down

0 comments on commit 58ecd91

Please sign in to comment.