Skip to content

Commit

Permalink
test(array): repro #7371
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jan 17, 2019
1 parent f424fe4 commit ced6251
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/types.array.test.js
Expand Up @@ -1113,6 +1113,31 @@ describe('types array', function() {
});
});

describe('options', function() {
let options;

beforeEach(function() {
options = Object.assign({}, mongoose.Schema.Types.Array.options);
});

afterEach(function() {
mongoose.Schema.Types.Array.options = options;
});

it('castNonArrays (gh-7371)', function() {
mongoose.Schema.Types.Array.options.castNonArrays = false;

const schema = new Schema({ arr: [String] });
const Model = db.model('gh7371', schema);

const doc = new Model({ arr: 'fail' });
assert.ok(doc.validateSync().errors);
assert.equal(doc.validateSync().errors['arr'].name, 'CastError');

return Promise.resolve();
});
});

describe('nonAtomicPush()', function() {
it('works', function(done) {
const U = db.model('User');
Expand Down

0 comments on commit ced6251

Please sign in to comment.