UNPKG

jaywalk

Version:
37 lines 1.24 kB
"use strict"; var test = require('blue-tape'); var index_1 = require('../index'); test('any', function (t) { t.test('default value', function (t) { var schema = new index_1.Types.Any({ default: 123 }); var validate = index_1.compile(schema); t.test('structural test', function (t) { t.equal(index_1.assert(schema, null), 1); t.equal(index_1.assert(schema, 'abc'), 1); t.end(); }); t.test('should use default value', function (t) { return validate(null) .then(function (res) { t.equal(res, 123); }); }); t.test('should use validation value', function (t) { return validate('abc') .then(function (res) { t.equal(res, 'abc'); }); }); t.test('extend to new schema', function (t) { var newSchema = index_1.Utils.extendSchema(schema, { default: 456 }); var validate = index_1.compile(newSchema); return validate(null) .then(function (res) { t.equal(res, 456); }); }); }); }); //# sourceMappingURL=any.spec.js.map