Last active
July 24, 2018 07:40
-
-
Save Veraclins/65fd95e468395645778e280132726126 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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(); | |
| }); | |
| }); | |
| }); |
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.
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
I find the test to be easily understood, good job.