-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(connect signin form to database):
connect signin form to database [Starts #165422358]
- Loading branch information
Showing
6 changed files
with
168 additions
and
143 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,106 @@ | ||
// /* eslint-disable no-undef */ | ||
// import chaiHttp from 'chai-http'; | ||
// import chai, { expect } from 'chai'; | ||
/* eslint-disable no-undef */ | ||
import chaiHttp from 'chai-http'; | ||
import chai, { expect } from 'chai'; | ||
|
||
// import app from '../app'; | ||
import app from '../app'; | ||
|
||
// chai.use(chaiHttp); | ||
chai.use(chaiHttp); | ||
|
||
// describe('Testing User Controller', () => { | ||
// describe('Testing signin controller', () => { | ||
// const signinUrl = '/api/auth/signin'; | ||
// it( | ||
// 'should login when all the parameters are given', | ||
// (done) => { | ||
// chai.request(app) | ||
// .post(signinUrl) | ||
// .send({ | ||
// email: 'banka2@banka.com', | ||
// password: 'passworD2@', | ||
// }) | ||
describe('Testing User Controller', () => { | ||
describe('Testing signin controller', () => { | ||
const signinUrl = '/api/auth/signin'; | ||
it( | ||
'should login when all the parameters are given', | ||
async () => { | ||
const response = await chai.request(app) | ||
.post(signinUrl) | ||
.send({ | ||
email: 'banka872@banka4.com', | ||
password: 'passworD4@', | ||
}); | ||
expect(response.body.data[0]).to.be.an('object'); | ||
expect(response.body.status).to.equal('success'); | ||
expect(response.body.data[0]).to.have.property('id'); | ||
expect(response.body.data[0]).to.have.property('email'); | ||
expect(response.body.data[0]).to.have.property('firstName'); | ||
expect(response.body.data[0]).to.have.property('lastName'); | ||
expect(response.body.data[0]).to.have.property('type'); | ||
expect(response.body.data[0]).to.have.property('isAdmin'); | ||
expect(response.body.data[0]).to.have.property('token'); | ||
}, | ||
); | ||
|
||
// .end((error, response) => { | ||
// expect(response.body).to.be.an('object'); | ||
// expect(response).to.have.status(200); | ||
// expect(response.body.data).to.be.a('object'); | ||
// expect(response.body.data.loggedUser).to.have.property('id'); | ||
// expect(response.body.data.loggedUser).to.have.property('email'); | ||
// expect(response.body.data).to.have.property('token'); | ||
// done(); | ||
// }); | ||
// }, | ||
// ); | ||
it( | ||
'should not signin a user when the email is missing', | ||
async () => { | ||
const response = await chai.request(app) | ||
.post(signinUrl) | ||
.send({ | ||
password: 'passworD4@', | ||
}); | ||
expect(response.body).to.be.an('object'); | ||
expect(response.body.status).to.equal('success'); | ||
expect(response.body.data[0]).to.equal('invalid email address'); | ||
}, | ||
); | ||
|
||
// it('should not signin a user when the email is missing', (done) => { | ||
// chai.request(app) | ||
// .post(signinUrl) | ||
// .send({ | ||
// password: 'passworD4@', | ||
// }) | ||
// .end((error, response) => { | ||
// expect(response.body).to.be.an('object'); | ||
// expect(response.body.status).to.equal('error'); | ||
// expect(response.body.data).to.equal('incorrect data'); | ||
// done(); | ||
// }); | ||
// }); | ||
it( | ||
'should not signin a user when the email does not exist', | ||
async () => { | ||
const response = await chai.request(app) | ||
.post(signinUrl) | ||
.send({ | ||
email: 'banka876@banka4.com', | ||
password: 'passworD4@', | ||
}); | ||
expect(response.body).to.be.an('object'); | ||
expect(response.body.status).to.equal('success'); | ||
expect(response.body.data[0]).to.equal('email does not exist'); | ||
}, | ||
); | ||
|
||
// it('should not signin a user when the email does not exist', (done) => { | ||
// chai.request(app) | ||
// .post(signinUrl) | ||
// .send({ | ||
// email: 'banka5@banka.com', | ||
// password: 'passworD4@', | ||
// }) | ||
// .end((error, response) => { | ||
// expect(response.body).to.be.an('object'); | ||
// expect(response.body.status).to.equal('error'); | ||
// expect(response.body.data).to.equal('incorrect data'); | ||
// done(); | ||
// }); | ||
// }); | ||
it( | ||
'should not login a user when the password is missing', | ||
async () => { | ||
const response = await chai.request(app) | ||
.post(signinUrl) | ||
.send({ | ||
email: 'banka872@banka4.com', | ||
}); | ||
expect(response.body).to.be.an('object'); | ||
expect(response.body.status).to.equal('success'); | ||
expect(response.body.data[0]).to.equal('Password should contain atleast 8 characters, 1 uppercase letter, 1 lowercase letter, 1 number and 1 symbol or character'); | ||
}, | ||
); | ||
|
||
// it('should not register a user when the password is missing', (done) => { | ||
// chai.request(app) | ||
// .post(signinUrl) | ||
// .send({ | ||
// email: 'banka4@banka.com', | ||
// }) | ||
// .end((error, response) => { | ||
// expect(response.body).to.be.an('object'); | ||
// expect(response.body.status).to.equal('error'); | ||
// expect(response.body.data).to.equal('incorrect data'); | ||
// done(); | ||
// }); | ||
// }); | ||
it( | ||
'should not login a user when the password is incorrect', | ||
async () => { | ||
const response = await chai.request(app) | ||
.post(signinUrl) | ||
.send({ | ||
email: 'banka872@banka4.com', | ||
password: 'passworD4@@', | ||
}); | ||
expect(response.body).to.be.an('object'); | ||
expect(response.body.status).to.equal('success'); | ||
expect(response.body.data[0]).to.equal('incorrect password'); | ||
}, | ||
); | ||
|
||
// it('should not register a user when the password do not meet requirement', (done) => { | ||
// chai.request(app) | ||
// .post(signinUrl) | ||
// .send({ | ||
// email: 'banka2@banka.com', | ||
// password: 'passworD4', | ||
// }) | ||
// .end((error, response) => { | ||
// expect(response.body).to.be.an('object'); | ||
// expect(response.body.status).to.equal('error'); | ||
// expect(response.body.data).to.equal('incorrect data'); | ||
// done(); | ||
// }); | ||
// }); | ||
// }); | ||
// }); | ||
it( | ||
'should not register a user when the password do not meet requirement', | ||
async () => { | ||
const response = await chai.request(app) | ||
.post(signinUrl) | ||
.send({ | ||
email: 'banka872@banka4.com', | ||
password: 'passworD4', | ||
}); | ||
expect(response.body).to.be.an('object'); | ||
expect(response.body.status).to.equal('success'); | ||
expect(response.body.data[0]).to.equal('Password should contain atleast 8 characters, 1 uppercase letter, 1 lowercase letter, 1 number and 1 symbol or character'); | ||
}, | ||
); | ||
}); | ||
}); |
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