@@ -12,12 +12,29 @@ describe('Fake server', () => {
12
12
13
13
db . posts = [ { id : 1 , body : 'foo' } , { id : 2 , body : 'bar' } ]
14
14
15
+ db . comments = [
16
+ { id : 1 , body : 'foo' , published : true , postId : 1 , userId : 1 } ,
17
+ { id : 2 , body : 'bar' , published : false , postId : 1 , userId : 2 } ,
18
+ { id : 3 , body : 'baz' , published : false , postId : 2 , userId : 1 } ,
19
+ { id : 4 , body : 'qux' , published : true , postId : 2 , userId : 2 } ,
20
+ { id : 5 , body : 'quux' , published : false , postId : 2 , userId : 1 }
21
+ ]
22
+
15
23
server = jsonServer . create ( )
16
24
router = jsonServer . router ( db , { _isFake : true } )
17
25
server . use ( jsonServer . defaults ( ) )
18
26
server . use ( router )
19
27
} )
20
28
29
+ describe ( 'GET /:parent/:parentId/:resource' , ( ) => {
30
+ test ( 'should respond with json and corresponding nested resources' , ( ) =>
31
+ request ( server )
32
+ . get ( '/posts/1/comments' )
33
+ . expect ( 'Content-Type' , / j s o n / )
34
+ . expect ( [ db . comments [ 0 ] , db . comments [ 1 ] ] )
35
+ . expect ( 200 ) )
36
+ } )
37
+
21
38
describe ( 'POST /:resource' , ( ) => {
22
39
test ( 'should not create a resource' , async ( ) => {
23
40
await request ( server )
0 commit comments