Skip to content

Instantly share code, notes, and snippets.

@frankhn
Last active March 13, 2019 15:10
Show Gist options
  • Save frankhn/3d22330cfbf93a78bb1e68f2c575c666 to your computer and use it in GitHub Desktop.
Save frankhn/3d22330cfbf93a78bb1e68f2c575c666 to your computer and use it in GitHub Desktop.
import chai from ('chai').should;
import server from '../../app';
import chaiHttp from 'chai-http';
chai.use(chaiHttp);
describe('it should be able to apdate the article', () => {
it('should return the 201 status for success update', (done) => {
const article = {
title:"kacyiru",
body:"telecom house"
}
chai.request(server)
.put('/api/v1/article/1')
.send(article)
.end((err, res) => {
res.should.have.status(201);
done();
});
});
});
@mystere10
Copy link

Thanks for the job
But you didn't specify the extension of this file
The test is not complete, please try to add more tests as you tested only the status

@mwibutsa
Copy link

Try to use PUT when you are not updating a specific entity
https://spring.io/understanding/REST

@Inclet
Copy link

Inclet commented Mar 13, 2019

Good job, man!!

But here are one thing you need to change:
1. describe('it should be able to update an article', (req, res) => { you don't need res and req as parameters of the callback in Describe.

@jnkindi
Copy link

jnkindi commented Mar 13, 2019

  • You have only tested the status code. you should also test values of values that are returned.

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