UNPKG

jaywalk

Version:
34 lines 1.14 kB
"use strict"; var test = require('blue-tape'); var index_1 = require('../index'); test('mutate', function (t) { t.test('uses', function (t) { var schema = new index_1.Types.String({ uses: [ new index_1.Types.Mutate({ name: 'toLower', mutate: function (str) { return str.toLowerCase(); } }), new index_1.Types.Whitelist({ whitelist: ['hey'] }) ] }); var validate = index_1.compile(schema); t.test('should validate with mutation', function (t) { return validate('HEY') .then(function (value) { t.equal(value, 'HEY'); }); }); t.test('should fail with non-whitelisted lower string', function (t) { t.plan(2); return validate('invalid') .catch(function (err) { t.equal(err.errors.length, 1); t.deepEqual(err.errors[0].keyword, 'whitelist'); }); }); }); }); //# sourceMappingURL=mutate.spec.js.map