UNPKG

conditional

Version:

A preconditions package based on Google's Preconditions library

40 lines (35 loc) 1.35 kB
(function() { var InvalidTypeError, checkNumberType; require('./helpers/test_helper'); checkNumberType = preconditions.checkNumberType, InvalidTypeError = preconditions.InvalidTypeError; describe('test number type precondition', function() { it("boolean 'true' values are not numbers", function() { var wrapper; wrapper = function() { return checkNumberType(true, 'invalid numerical value'); }; return assert.throws(wrapper, InvalidTypeError, 'invalid numerical value'); }); it("boolean 'false' values are not numbers", function() { var wrapper; wrapper = function() { return checkNumberType(false, 'invalid numerical value'); }; return assert.throws(wrapper, InvalidTypeError, 'invalid numerical value'); }); it('arrays are not numbers', function() { var wrapper; wrapper = function() { return checkNumberType([5], 'invalid numerical value'); }; return assert.throws(wrapper, InvalidTypeError, 'invalid numerical value'); }); return it('objects are not numbers', function() { var wrapper; wrapper = function() { return checkNumberType(new Object, 'invalid numerical value'); }; return assert.throws(wrapper, InvalidTypeError, 'invalid numerical value'); }); }); }).call(this);