Last active
March 13, 2019 14:43
-
-
Save mwibutsa/adb612ac4c18ea6ad60b7d50e95a0aa4 to your computer and use it in GitHub Desktop.
Microsession TDD
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 chai from 'chai'; | |
import chaihttp from 'chai-http'; | |
import app from '../app'; | |
chai.should(); | |
chai.use(chaihttp); | |
describe ('TEST GET ARTICLES', () => { | |
it ('should get Articles', (done) => { | |
chai.request(app).get('/api/v1/articles').then((res => { | |
res.should.have.status(200); | |
res.body.should.be.a('object'); | |
res.body.should.have.property('status').eql(200); | |
res.body.should.have.property('data'); | |
res.body.data.should.be.a('array'); | |
res.body.data.forEach((data) => { | |
data.should.be.a('object'); | |
data.should.have.propery('title'); | |
data.should.have.propery('content'); | |
data.should.have.propery('id'); | |
data.should.have.property('author'); | |
}); | |
}).catch(error => console.log(error)) | |
}); | |
}); |
-Eslint
Great Job!!
Here are few things to change:
- You also need to test actual data it returned. For example, write
res.body.data[0].should.have.property('title').eql('Something...')
instead ofres.body.data[0].should.have.property('title')
Meanwhile, You did a great job!!!
Good job!
- Please eslint
- When writing describe u should use a meaningful phrase
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`
{
"articles":[{
"slug": "how-to-train-your-dragon",
"title": "How to train your dragon",
"description": "Ever wonder how?",
"body": "It takes a Jacobian",
"tagList": ["dragons", "training"],
"createdAt": "2016-02-18T03:22:56.637Z",
"updatedAt": "2016-02-18T03:48:35.824Z",
"favorited": false,
"favoritesCount": 0,
"author": {
"username": "jake",
"bio": "I work at statefarm",
"image": "https://i.stack.imgur.com/xHWG8.jpg",
"following": false
}
}, {
"slug": "how-to-train-your-dragon-2",
"title": "How to train your dragon 2",
"description": "So toothless",
"body": "It a dragon",
"tagList": ["dragons", "training"],
"createdAt": "2016-02-18T03:22:56.637Z",
"updatedAt": "2016-02-18T03:48:35.824Z",
"favorited": false,
"favoritesCount": 0,
"author": {
"username": "jake",
"bio": "I work at statefarm",
"image": "https://i.stack.imgur.com/xHWG8.jpg",
"following": false
}
}],
"articlesCount": 2
}
`