UNPKG

@incdevco/framework

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