Skip to content

Commit 4ff5f52

Browse files
committed
test(document): repro #5780
1 parent d373c81 commit 4ff5f52

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/document.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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',

0 commit comments

Comments
 (0)