File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -4768,6 +4768,26 @@ describe('document', function() {
47684768 } ) ;
47694769 } ) ;
47704770
4771+ it ( 'handles array defaults correctly (gh-5780)' , function ( done ) {
4772+ var testSchema = new Schema ( {
4773+ nestedArr : {
4774+ type : [ [ Number ] ] ,
4775+ default : [ [ 0 , 1 ] ]
4776+ }
4777+ } ) ;
4778+
4779+ var Test = db . model ( 'gh5780' , testSchema ) ;
4780+
4781+ var t = new Test ( { } ) ;
4782+ assert . deepEqual ( t . toObject ( ) . nestedArr , [ [ 0 , 1 ] ] ) ;
4783+
4784+ t . nestedArr . push ( [ 1 , 2 ] ) ;
4785+ var t2 = new Test ( { } ) ;
4786+ assert . deepEqual ( t2 . toObject ( ) . nestedArr , [ [ 0 , 1 ] ] ) ;
4787+
4788+ done ( ) ;
4789+ } ) ;
4790+
47714791 it ( 'Single nested subdocs using discriminator can be modified (gh-5693)' , function ( done ) {
47724792 var eventSchema = new Schema ( { message : String } , {
47734793 discriminatorKey : 'kind' ,
You can’t perform that action at this time.
0 commit comments