@@ -19,7 +19,7 @@ describe('Fake server', () => {
19
19
} )
20
20
21
21
describe ( 'POST /:resource' , ( ) => {
22
- test ( 'should respond with json, create a resource and increment id ' , async ( ) => {
22
+ test ( 'should not create a resource' , async ( ) => {
23
23
await request ( server )
24
24
. post ( '/posts' )
25
25
. send ( { body : 'foo' , booleanValue : true , integerValue : 1 } )
@@ -28,13 +28,12 @@ describe('Fake server', () => {
28
28
. expect ( 'Content-Type' , / j s o n / )
29
29
. expect ( { id : 3 , body : 'foo' , booleanValue : true , integerValue : 1 } )
30
30
. expect ( 201 )
31
- // assert it was not created in database
32
31
assert . equal ( db . posts . length , 2 )
33
32
} )
34
33
} )
35
34
36
35
describe ( 'PUT /:resource/:id' , ( ) => {
37
- test ( 'should respond with json and replace resource' , async ( ) => {
36
+ test ( 'should not replace resource' , async ( ) => {
38
37
const post = { id : 1 , booleanValue : true , integerValue : 1 }
39
38
const res = await request ( server )
40
39
. put ( '/posts/1' )
@@ -47,13 +46,12 @@ describe('Fake server', () => {
47
46
// TODO find a "supertest" way to test this
48
47
// https://github.com/typicode/json-server/issues/396
49
48
assert . deepStrictEqual ( res . body , post )
50
- // assert it was not created in database
51
49
assert . notDeepStrictEqual ( db . posts [ 0 ] , post )
52
50
} )
53
51
} )
54
52
55
53
describe ( 'PATCH /:resource/:id' , ( ) => {
56
- test ( 'should respond with json and update resource' , async ( ) => {
54
+ test ( 'should not update resource' , async ( ) => {
57
55
const partial = { body : 'bar' }
58
56
const post = { id : 1 , body : 'bar' }
59
57
const res = await request ( server )
@@ -63,18 +61,16 @@ describe('Fake server', () => {
63
61
. expect ( post )
64
62
. expect ( 200 )
65
63
assert . deepStrictEqual ( res . body , post )
66
- // assert it was not created in database
67
64
assert . notDeepStrictEqual ( db . posts [ 0 ] , post )
68
65
} )
69
66
} )
70
67
71
68
describe ( 'DELETE /:resource/:id' , ( ) => {
72
- test ( 'should respond with empty data, destroy resource and dependent resources ' , async ( ) => {
69
+ test ( 'should not destroy resource' , async ( ) => {
73
70
await request ( server )
74
71
. del ( '/posts/1' )
75
72
. expect ( { } )
76
73
. expect ( 200 )
77
- // assert it was not created in database
78
74
assert . equal ( db . posts . length , 2 )
79
75
} )
80
76
} )
0 commit comments