@@ -29,6 +29,10 @@ describe('Server', function() {
2929 { id : 5 , published : false , postId : 2 } ,
3030 ]
3131
32+ db . refs = [
33+ { id : 'abcd-1234' , url : 'http://example.com' , postId : 1 }
34+ ]
35+
3236 server = jsonServer ( db )
3337 } )
3438
@@ -166,19 +170,34 @@ describe('Server', function() {
166170
167171
168172 describe ( 'POST /:resource' , function ( ) {
169- it ( 'should respond with json and create a resource' , function ( done ) {
170- request ( server )
171- . post ( '/posts' )
172- . send ( { body : 'foo' , booleanValue : 'true' , integerValue : '1' } )
173- . expect ( 'Content-Type' , / j s o n / )
174- . expect ( { id : 3 , body : 'foo' , booleanValue : true , integerValue : 1 } )
175- . expect ( 200 )
176- . end ( function ( err , res ) {
177- if ( err ) return done ( err )
178- assert . equal ( db . posts . length , 3 )
179- done ( )
180- } )
181- } )
173+ it ( 'should respond with json, create a resource and increment id' ,
174+ function ( done ) {
175+ request ( server )
176+ . post ( '/posts' )
177+ . send ( { body : 'foo' , booleanValue : 'true' , integerValue : '1' } )
178+ . expect ( 'Content-Type' , / j s o n / )
179+ . expect ( { id : 3 , body : 'foo' , booleanValue : true , integerValue : 1 } )
180+ . expect ( 200 )
181+ . end ( function ( err , res ) {
182+ if ( err ) return done ( err )
183+ assert . equal ( db . posts . length , 3 )
184+ done ( )
185+ } )
186+ } )
187+
188+ it ( 'should respond with json, create a resource and generate string id' ,
189+ function ( done ) {
190+ request ( server )
191+ . post ( '/refs' )
192+ . send ( { url : 'http://foo.com' , postId : '1' } )
193+ . expect ( 'Content-Type' , / j s o n / )
194+ . expect ( 200 )
195+ . end ( function ( err , res ) {
196+ if ( err ) return done ( err )
197+ assert . equal ( db . refs . length , 2 )
198+ done ( )
199+ } )
200+ } )
182201 } )
183202
184203 describe ( 'PUT /:resource/:id' , function ( ) {
0 commit comments