Skip to content

Instantly share code, notes, and snippets.

@Veraclins
Last active July 24, 2018 07:40
Show Gist options
  • Select an option

  • Save Veraclins/65fd95e468395645778e280132726126 to your computer and use it in GitHub Desktop.

Select an option

Save Veraclins/65fd95e468395645778e280132726126 to your computer and use it in GitHub Desktop.
import chai from 'chai';
import chaiHttp from 'chai-http';
import { server } from '../index'; // Server is defined in the api entry point (index.js)
const expect = chai.expect;
chai.use(chaiHttp);
describe('When a User sends a GET get Request to /api/profiles/:username', () => {
it('it should return the profile of the user with the provided username', (done) => {
chai.request(server)
.post('/api/profiles/:username')
.end((err, res) => {
expect(res).to.have.status(200);
expect(res.body).to.have.property('profile');
expect(res.body).to.have.nested.property('profile.username');
expect(res.body).to.have.nested.property('profile.bio');
done();
});
});
});
@yomigeek
Copy link

I find the test to be easily understood, good job.

@Oluwafayokemi
Copy link

Nice job!
I think you should try to return a message when as part of your response
You could also try to test for the fail of the test. This can help you to identify when there is a problem with the function.

@chukwuemekachm
Copy link

Well, formatted. But I feel your test is sending a different request from what it tells us it does.
You are making a POST request and your description says it's a GET.
I feel you should look at that the request verb/method you are using.

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