UNPKG

@incdevco/framework

Version:
55 lines (30 loc) 952 B
var Expect = require('chai').expect; var Validator = require('./index'); describe('framework/validators/is-number', function () { 'use strict'; var validator; beforeEach(function () { validator = new Validator(); }); it('should resolve when submitted value is a number', function (done) { var input = 12345; validator.validate(input) .then(function (actual) { Expect(actual).to.equal(true, 'actual'); done(); }) .catch(done); }); it('should reject when submitted value is not a number', function (done) { var input = {}; validator.validate(input) .then(function () { throw new Error('resolved'); }) .catch(function (exception) { Expect(exception.message).to.equal('Must be a number.', 'exception.message'); done(); }) .catch(done); }); });