UNPKG

@incdevco/framework

Version:
51 lines (28 loc) 895 B
var Expect = require('chai').expect; var Validator = require('./index'); describe('framework/validators/numeric', function () { 'use strict'; var validator; beforeEach(function () { validator = new Validator(); }); it('should resolve when value is numeric', function (done) { validator.validate('12345') .then(function (actual) { Expect(actual).to.equal(true, 'actual'); done(); }) .catch(done); }); it('should reject when value is not numeric', function (done) { validator.validate('test&^%') .then(function () { throw new Error('resolved'); }) .catch(function (exception) { Expect(exception.message).to.equal('Only numeric characters allowed', 'exception.message'); done(); }) .catch(done); }); });