@@ -24,12 +24,17 @@ describe('Server', function () {
2424 { id : 3 , body : 'photo' }
2525 ]
2626
27+ db . users = [
28+ { id : 1 , username : 'Jim' } ,
29+ { id : 2 , username : 'George' }
30+ ]
31+
2732 db . comments = [
28- { id : 1 , published : true , postId : 1 } ,
29- { id : 2 , published : false , postId : 1 } ,
30- { id : 3 , published : false , postId : 2 } ,
31- { id : 4 , published : false , postId : 2 } ,
32- { id : 5 , published : false , postId : 2 }
33+ { id : 1 , published : true , postId : 1 , userId : 1 } ,
34+ { id : 2 , published : false , postId : 1 , userId : 2 } ,
35+ { id : 3 , published : false , postId : 2 , userId : 1 } ,
36+ { id : 4 , published : false , postId : 2 , userId : 2 } ,
37+ { id : 5 , published : false , postId : 2 , userId : 1 }
3338 ]
3439
3540 db . refs = [
@@ -242,6 +247,31 @@ describe('Server', function () {
242247 } )
243248 } )
244249
250+ describe ( 'GET /:resource/:id?_expand=' , function ( ) {
251+ it ( 'should respond with corresponding resource and expanded inner resources' , function ( done ) {
252+ var comments = db . comments [ 0 ]
253+ comments . posts = [ db . posts [ 0 ] ]
254+ request ( server )
255+ . get ( '/comments/1?_expand=posts' )
256+ . expect ( 'Content-Type' , / j s o n / )
257+ . expect ( comments )
258+ . expect ( 200 , done )
259+ } )
260+ } )
261+
262+ describe ( 'GET /:resource/:id?_expand=&_expand=' , function ( ) {
263+ it ( 'should respond with corresponding resource and expanded inner resources' , function ( done ) {
264+ var comments = db . comments [ 0 ]
265+ comments . posts = [ db . posts [ 0 ] ]
266+ comments . users = [ db . users [ 0 ] ]
267+ request ( server )
268+ . get ( '/comments/1?_expand=posts&_expand=users' )
269+ . expect ( 'Content-Type' , / j s o n / )
270+ . expect ( comments )
271+ . expect ( 200 , done )
272+ } )
273+ } )
274+
245275 describe ( 'POST /:resource' , function ( ) {
246276 it ( 'should respond with json, create a resource and increment id' ,
247277 function ( done ) {
0 commit comments