@@ -572,15 +572,35 @@ describe('Parse.Object testing', () => {
572572 const obj = new TestObject ( ) ;
573573 obj . set ( 'items' , [ { value : 'a' , count : 5 } , { value : 'b' , count : 1 } ] ) ;
574574 await obj . save ( ) ;
575-
576575 obj . increment ( 'items.0.count' , 15 ) ;
577576 obj . increment ( 'items.1.count' , 4 ) ;
578577 await obj . save ( ) ;
579-
578+ expect ( obj . toJSON ( ) . items [ 0 ] . value ) . toBe ( 'a' ) ;
579+ expect ( obj . toJSON ( ) . items [ 1 ] . value ) . toBe ( 'b' ) ;
580+ expect ( obj . toJSON ( ) . items [ 0 ] . count ) . toBe ( 20 ) ;
581+ expect ( obj . toJSON ( ) . items [ 1 ] . count ) . toBe ( 5 ) ;
580582 const query = new Parse . Query ( TestObject ) ;
581583 const result = await query . get ( obj . id ) ;
584+ expect ( result . get ( 'items' ) [ 0 ] . value ) . toBe ( 'a' ) ;
585+ expect ( result . get ( 'items' ) [ 1 ] . value ) . toBe ( 'b' ) ;
582586 expect ( result . get ( 'items' ) [ 0 ] . count ) . toBe ( 20 ) ;
583587 expect ( result . get ( 'items' ) [ 1 ] . count ) . toBe ( 5 ) ;
588+ expect ( result . get ( 'items' ) ) . toEqual ( obj . get ( 'items' ) ) ;
589+ } ) ;
590+
591+ it_only_db ( 'mongo' ) ( 'can increment array nested fields missing index' , async ( ) => {
592+ const obj = new TestObject ( ) ;
593+ obj . set ( 'items' , [ ] ) ;
594+ await obj . save ( ) ;
595+ obj . increment ( 'items.1.count' , 15 ) ;
596+ await obj . save ( ) ;
597+ expect ( obj . toJSON ( ) . items [ 0 ] ) . toBe ( null ) ;
598+ expect ( obj . toJSON ( ) . items [ 1 ] . count ) . toBe ( 15 ) ;
599+ const query = new Parse . Query ( TestObject ) ;
600+ const result = await query . get ( obj . id ) ;
601+ expect ( result . get ( 'items' ) [ 0 ] ) . toBe ( null ) ;
602+ expect ( result . get ( 'items' ) [ 1 ] . count ) . toBe ( 15 ) ;
603+ expect ( result . get ( 'items' ) ) . toEqual ( obj . get ( 'items' ) ) ;
584604 } ) ;
585605
586606 it ( 'addUnique with object' , function ( done ) {
0 commit comments