@@ -119,6 +119,28 @@ describe('Objects', function(){
119119 }
120120 } ) ;
121121 } ) ;
122+ it ( 'should not update prop when query not match' , function ( done ) {
123+ gameScore . set ( 'score' , 10000 ) ;
124+ gameScore . save ( null , {
125+ query : new AV . Query ( GameScore ) . equalTo ( 'score' , - 1 )
126+ } ) . then ( function ( result ) {
127+ done ( new Error ( 'should not success' ) ) ;
128+ } , function ( error ) {
129+ expect ( error . code ) . to . be . eql ( 305 ) ;
130+ done ( ) ;
131+ } ) ;
132+ } ) ;
133+ it ( 'should update prop when query match' , function ( done ) {
134+ gameScore . set ( 'score' , 10000 ) ;
135+ gameScore . save ( null , {
136+ query : new AV . Query ( GameScore ) . notEqualTo ( 'score' , - 1 ) ,
137+ fetchWhenSave : true
138+ } ) . then ( function ( result ) {
139+ done ( ) ;
140+ } , function ( error ) {
141+ done ( error ) ;
142+ } ) ;
143+ } ) ;
122144 } ) ;
123145
124146 describe ( "Deleting Objects" , function ( ) {
@@ -300,9 +322,10 @@ describe('Objects', function(){
300322 person2 . set ( 'age' , 0 ) ;
301323 person2 . increment ( 'age' , 9 ) ;
302324 person2 . save ( ) . then ( function ( person ) {
303- person . fetchWhenSave ( true ) ;
304325 person . increment ( 'age' , 10 ) ;
305- person . save ( ) . then ( function ( p ) {
326+ person . save ( null , {
327+ fetchWhenSave : true
328+ } ) . then ( function ( p ) {
306329 expect ( p . get ( 'age' ) ) . to . be ( 19 ) ;
307330 done ( ) ;
308331 } , function ( err ) {
@@ -315,9 +338,10 @@ describe('Objects', function(){
315338
316339 it ( "should fetch when save when creating new object." , function ( done ) {
317340 var p = new Person ( ) ;
318- p . fetchWhenSave ( true ) ;
319341 p . set ( 'pname' , 'dennis' ) ;
320- p . save ( ) . then ( function ( person ) {
342+ p . save ( null , {
343+ fetchWhenSave : true
344+ } ) . then ( function ( person ) {
321345 expect ( person . get ( 'company' ) ) . to . be ( 'leancloud' ) ;
322346 done ( ) ;
323347 } ) . catch ( function ( err ) {
0 commit comments