Skip to content

Instantly share code, notes, and snippets.

@kayroy247
Last active March 21, 2019 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kayroy247/c01d254d972c759396ff3c8478d32962 to your computer and use it in GitHub Desktop.
Save kayroy247/c01d254d972c759396ff3c8478d32962 to your computer and use it in GitHub Desktop.
Author's Haven Signup Test Demo
describe('Test User Registration', () => {
it('Should register a user and return user object', (done) => {
const user = {
username: 'kaykay',
email: 'user@authorshaven.com',
password: 'itsasecret'
};
request(app)
.post('api/users')
.send(user)
.end((err, res) => {
expect(res).to.have.status(201);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('user');
expect(res.body.user).to.have.property('username')
.to.be.equal('kaykay');
expect(res.body.user).to.have.property('email')
.to.be.equal('user@authorshaven.com');
expect(res.body.user).to.have.property('password')
.to.be.equal('itsasecret');
});
done();
});
});
@Joyce-O
Copy link

Joyce-O commented Mar 20, 2019

It is good that you tried to capture as many edge cases as possible. I want to suggest that you use a fake email address so as to avoid exposing sensitive data to someone who may misuse them.

@Bobjayafam
Copy link

The test was well written. The returned user object should also contain a token upon registration. I also agree with @Joyce-O that you use fake emails such as user@test.com instead of a real email address.

@kayroy247
Copy link
Author

Thank you @Joyce-O and @Bobjayafam for your feedback. I will change the email address I used.

@innocentEdosa
Copy link

Nice work

@Jesse-efe
Copy link

Jesse-efe commented Mar 21, 2019

well done, this is a well-detailed test

@kayroy247
Copy link
Author

Thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment