mirror of
https://github.com/typicode/json-server.git
synced 2025-08-02 19:52:20 +08:00
Fix PUT should replace resource
This commit is contained in:
@ -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()
|
||||
})
|
||||
})
|
||||
|
@ -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' })
|
||||
|
Reference in New Issue
Block a user