UNPKG

@incdevco/framework

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