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)) | |
}); | |
}); |
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
-Eslint