Skip to content

Commit

Permalink
strictBool test rewritten to support Node < 4
Browse files Browse the repository at this point in the history
  • Loading branch information
c0d0g3n committed Jun 18, 2017
1 parent 0fb09d9 commit aa6d05a
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/schema.boolean.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,29 @@ describe('schematype', function() {
assert.strictEqual(true, m3.b);
done();
});
it('strictBool option (gh-5211)', function() {
console.log('chekc');
it('strictBool option (gh-5211)', function(done) {
var db = start(),
s1 = new Schema({b: {type: Boolean, strictBool: true}}),
M1 = db.model('StrictBoolTrue', s1);
db.close();

var m1 = new M1;
var strictValues = [true, false, 'true', 'false', 0, 1, '0', '1'];
var validatePromises = strictValues.map(function(value) {
m1.b = value;
return m1.validate();

var testsRemaining = strictValues.length;
strictValues.forEach(function (value) {
var doc = new M1;
doc.b = value;
doc.validate(function (error) {
if (error) {
// test fails as soon as one value fails
return done(error)
}
if (!--testsRemaining) {
return done()
}
});
});

return global.Promise.all(validatePromises);
});
});
});

0 comments on commit aa6d05a

Please sign in to comment.