Skip to content

Commit da8462e

Browse files
committed
test: address code review comments
1 parent 4d3243f commit da8462e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/schematype.test.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,16 @@ describe('schematype', function() {
210210

211211
it('merges default validators (gh-14070)', function() {
212212
class TestSchemaType extends mongoose.SchemaType {}
213-
TestSchemaType.set('validate', v => typeof v === 'string');
213+
TestSchemaType.set('validate', checkIfString);
214214

215215
const schemaType = new TestSchemaType('test-path', {
216-
validate: v => v.length === 2
216+
validate: checkIfLength2
217217
});
218218

219+
assert.equal(schemaType.validators.length, 2);
220+
assert.equal(schemaType.validators[0].validator, checkIfString);
221+
assert.equal(schemaType.validators[1].validator, checkIfLength2);
222+
219223
let err = schemaType.doValidateSync([1, 2]);
220224
assert.ok(err);
221225
assert.equal(err.name, 'ValidatorError');
@@ -226,6 +230,13 @@ describe('schematype', function() {
226230

227231
err = schemaType.doValidateSync('ab');
228232
assert.ifError(err);
233+
234+
function checkIfString(v) {
235+
return typeof v === 'string';
236+
}
237+
function checkIfLength2(v) {
238+
return v.length === 2;
239+
}
229240
});
230241

231242
describe('set()', function() {

0 commit comments

Comments
 (0)