Skip to content

Instantly share code, notes, and snippets.

@mwibutsa
Last active March 13, 2019 14:43
Show Gist options
  • Save mwibutsa/adb612ac4c18ea6ad60b7d50e95a0aa4 to your computer and use it in GitHub Desktop.
Save mwibutsa/adb612ac4c18ea6ad60b7d50e95a0aa4 to your computer and use it in GitHub Desktop.
Microsession TDD
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))
});
});
@Inclet
Copy link

Inclet commented Mar 13, 2019

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 of res.body.data[0].should.have.property('title')

Meanwhile, You did a great job!!!

@mystere10
Copy link

Good job!

  1. Please eslint
  2. 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