Fix PUT should replace resource

This commit is contained in:
Typicode
2015-10-03 16:03:29 +02:00
parent 9f596a7a64
commit 2d278fbcb8
5 changed files with 21 additions and 16 deletions

View File

@ -408,17 +408,19 @@ describe('Server', function () {
})
describe('PUT /:resource/:id', function () {
it('should respond with json and update resource', function (done) {
it('should respond with json and replace resource', function (done) {
var post = {id: 1, booleanValue: true, integerValue: 1}
request(server)
.put('/posts/1')
.send({id: 1, body: 'bar', booleanValue: 'true', integerValue: '1'})
// body property omitted to test that the resource is replaced
.send({id: 1, booleanValue: 'true', integerValue: '1'})
.expect('Content-Type', /json/)
.expect({id: 1, body: 'bar', booleanValue: true, integerValue: 1})
.expect(post)
.expect(200)
.end(function (err, res) {
if (err) return done(err)
// assert it was created in database too
assert.deepEqual(db.posts[0], {id: 1, body: 'bar', booleanValue: true, integerValue: 1})
assert.deepEqual(db.posts[0], post)
done()
})
})

View File

@ -44,18 +44,18 @@ describe('Server', function () {
})
describe('PUT /:resource', function () {
it('should uptade resource', function (done) {
it('should update resource', function (done) {
var user = { name: 'bar' }
request(server)
.put('/user')
.send(user)
.expect(db.user)
.expect(user)
.expect(200, done)
})
})
describe('PATCH /:resource', function () {
it('should uptade resource', function (done) {
it('should update resource', function (done) {
request(server)
.patch('/user')
.send({ name: 'bar' })