Skip to content

Commit d1cece3

Browse files
committed
Refactor test
1 parent dde5636 commit d1cece3

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

__tests__/server/plural-fake.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Fake server', () => {
1919
})
2020

2121
describe('POST /:resource', () => {
22-
test('should respond with json, create a resource and increment id', async () => {
22+
test('should not create a resource', async () => {
2323
await request(server)
2424
.post('/posts')
2525
.send({ body: 'foo', booleanValue: true, integerValue: 1 })
@@ -28,13 +28,12 @@ describe('Fake server', () => {
2828
.expect('Content-Type', /json/)
2929
.expect({ id: 3, body: 'foo', booleanValue: true, integerValue: 1 })
3030
.expect(201)
31-
// assert it was not created in database
3231
assert.equal(db.posts.length, 2)
3332
})
3433
})
3534

3635
describe('PUT /:resource/:id', () => {
37-
test('should respond with json and replace resource', async () => {
36+
test('should not replace resource', async () => {
3837
const post = { id: 1, booleanValue: true, integerValue: 1 }
3938
const res = await request(server)
4039
.put('/posts/1')
@@ -47,13 +46,12 @@ describe('Fake server', () => {
4746
// TODO find a "supertest" way to test this
4847
// https://github.com/typicode/json-server/issues/396
4948
assert.deepStrictEqual(res.body, post)
50-
// assert it was not created in database
5149
assert.notDeepStrictEqual(db.posts[0], post)
5250
})
5351
})
5452

5553
describe('PATCH /:resource/:id', () => {
56-
test('should respond with json and update resource', async () => {
54+
test('should not update resource', async () => {
5755
const partial = { body: 'bar' }
5856
const post = { id: 1, body: 'bar' }
5957
const res = await request(server)
@@ -63,18 +61,16 @@ describe('Fake server', () => {
6361
.expect(post)
6462
.expect(200)
6563
assert.deepStrictEqual(res.body, post)
66-
// assert it was not created in database
6764
assert.notDeepStrictEqual(db.posts[0], post)
6865
})
6966
})
7067

7168
describe('DELETE /:resource/:id', () => {
72-
test('should respond with empty data, destroy resource and dependent resources', async () => {
69+
test('should not destroy resource', async () => {
7370
await request(server)
7471
.del('/posts/1')
7572
.expect({})
7673
.expect(200)
77-
// assert it was not created in database
7874
assert.equal(db.posts.length, 2)
7975
})
8076
})

0 commit comments

Comments
 (0)