UNPKG

@incdevco/framework

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