Last active
November 22, 2018 15:40
-
-
Save Danielshow/37721cfc28c72936b04be4eecfb2a341 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, should } from 'chai'; | |
const url = '../index'; | |
const testObject = { | |
emptyEmail: { | |
email: '', | |
password: 'tuij' | |
}, | |
wrongEmailFormat: { | |
email: 'danielopeyemi*', | |
password: 'opeyemi' | |
}, | |
correctInput: { | |
email: '[email protected]', | |
password: 'opeyemi' | |
} | |
}; | |
descibe('API Endpoint to Login Users on medium.com', () => { | |
it('Should return error if email field is empty', () => { | |
chai.request(url) | |
.post('/auth/signin') | |
.send(testObject.emptyEmail) | |
.then((res) => { | |
expect(res).to.have.status(400); | |
res.body.should.have.property('message').eql('Email field is empty'); | |
}); | |
}); | |
it('Should return error if email syntax is wrong', () => { | |
chai.request(url) | |
.post('/auth/signin') | |
.send(testObject.wrongEmailFormat) | |
.then((res) => { | |
expect(res).to.have.status(400); | |
res.body.should.have.property('message').eql('Email format is wrong'); | |
}); | |
}); | |
it('Should return ok if email and password field is correct', () => { | |
chai.request(url) | |
.post('/auth/signin') | |
.send(testObject.correctInput) | |
.then((res) => { | |
expect(res).to.have.status(200); | |
res.body.should.have.property('message').eql('Login Successful'); | |
}); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks good to me.