@@ -124,6 +124,44 @@ describe.onServer('Remote Methods', function() {
124124 app . use ( loopback . rest ( ) ) ;
125125 } ) ;
126126
127+ describe ( 'Model.create(data, callback)' , function ( ) {
128+ it ( 'creates model' , function ( done ) {
129+ var anObject = { first : 'June' } ;
130+ request ( app )
131+ . post ( '/users' )
132+ // sends an object
133+ . send ( anObject )
134+ . expect ( 'Content-Type' , / j s o n / )
135+ . expect ( 200 )
136+ . end ( function ( err , res ) {
137+ if ( err ) return done ( err ) ;
138+ expect ( res . body ) . to . have . property ( 'id' ) ;
139+ expect ( res . body ) . to . have . property ( 'first' , 'June' ) ;
140+ done ( ) ;
141+ } ) ;
142+ } ) ;
143+ // batch create must be tested with a remote request because there are
144+ // coercion being done on strong-remoting side
145+ it ( 'creates array of models' , function ( done ) {
146+ var arrayOfObjects = [
147+ { first : 'John' } , { first : 'Jane' } ,
148+ ] ;
149+ request ( app )
150+ . post ( '/users' )
151+ // sends an array of objects
152+ . send ( arrayOfObjects )
153+ . expect ( 'Content-Type' , / j s o n / )
154+ . expect ( 200 )
155+ . end ( function ( err , res ) {
156+ if ( err ) return done ( err ) ;
157+ expect ( res . body . length ) . to . eql ( 2 ) ;
158+ expect ( res . body ) . to . have . deep . property ( '[0].first' , 'John' ) ;
159+ expect ( res . body ) . to . have . deep . property ( '[1].first' , 'Jane' ) ;
160+ done ( ) ;
161+ } ) ;
162+ } ) ;
163+ } ) ;
164+ // destoryAll is not exposed as a remoteMethod by default
127165 describe ( 'Model.destroyAll(callback)' , function ( ) {
128166 it ( 'Delete all Model instances from data source' , function ( done ) {
129167 ( new TaskEmitter ( ) )
0 commit comments