Created
November 22, 2018 13:43
-
-
Save JohnMadakin/62a0a23cbfb4365995f7d24ccef34d5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import expect from 'expect'; | |
import request from 'supertest'; | |
import app from '../index'; | |
describe('Test for Signup', () => { | |
it('should login users', (done) => { | |
const userDetail = { | |
username: 'christain5', | |
password: 'password@1', | |
}; | |
request(app).post('/api/v1/auth/login') | |
.send(userDetail) | |
.expect(200) | |
.expect((res) => { | |
expect(res.body.message).toEqual('you have successfully signed in'); | |
expect(res.body.status).toEqual('Success'); | |
}) | |
.end(done); | |
}); | |
it('should reject users with empty username', (done) => { | |
const userDetail = { | |
username: ' ', | |
password: 'password@1', | |
}; | |
request(app).post('/api/v1/auth/login') | |
.send(userDetail) | |
.expect(400) | |
.expect((res) => { | |
expect(res.body.message).toEqual('invalid username'); | |
}) | |
.end(done); | |
}); | |
it('should reject users with invalid username format', (done) => { | |
const userDetail = { | |
username: '1234903TY', | |
password: 'password@1', | |
}; | |
request(app).post('/api/v1/auth/login') | |
.send(userDetail) | |
.expect(400) | |
.expect((res) => { | |
expect(res.body.message).toEqual('invalid username format'); | |
}) | |
.end(done); | |
}); | |
it('should reject users with invalid password', (done) => { | |
const userDetail = { | |
username: 'christain5', | |
password: 'password@', | |
}; | |
request(app).post('/api/v1/auth/login') | |
.send(userDetail) | |
.expect(400) | |
.expect((res) => { | |
expect(res.body.message).toEqual('invalid password'); | |
}) | |
.end(done); | |
}); | |
}); |
Great work! The test is well structured and detailed
Nice one
Nice one Edafe, code structure is great.
Nice one
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool one Edafe.