mirror of
https://github.com/typicode/json-server.git
synced 2025-07-27 20:23:34 +08:00
Fix PATCH test
This commit is contained in:
@ -584,17 +584,19 @@ describe('Server', () => {
|
|||||||
|
|
||||||
describe('PATCH /:resource/:id', () => {
|
describe('PATCH /:resource/:id', () => {
|
||||||
it('should respond with json and update resource', (done) => {
|
it('should respond with json and update resource', (done) => {
|
||||||
|
var partial = {body: 'bar'}
|
||||||
|
var post = {id: 1, body: 'bar'}
|
||||||
request(server)
|
request(server)
|
||||||
.patch('/posts/1')
|
.patch('/posts/1')
|
||||||
.send({body: 'bar'})
|
.send(partial)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect({id: 1, body: 'bar'})
|
.expect(post)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end((err, res) => {
|
.end((err, res) => {
|
||||||
if (err) return done(err)
|
if (err) return done(err)
|
||||||
assert.deepStrictEqual(res.body, post)
|
assert.deepStrictEqual(res.body, post)
|
||||||
// assert it was created in database too
|
// assert it was created in database too
|
||||||
assert.deepStrictEqual(db.posts[0], {id: 1, body: 'bar'})
|
assert.deepStrictEqual(db.posts[0], post)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user