Add failure scenarios tests for connection, appendToStream, deleteStream (wip)

This commit is contained in:
Nicolas Dextraze
2016-03-11 15:55:27 -08:00
parent b0a0af536d
commit 0b63df85e7
16 changed files with 420 additions and 32 deletions

View File

@ -8,4 +8,16 @@ module.exports.notNullOrEmpty = function(value, name) {
module.exports.notNull = function(value, name) {
if (value === null)
throw new Error(name + " is null.");
};
module.exports.isInteger = function(value, name) {
if (typeof value !== 'number' || value % 1 !== 0)
throw new TypeError(name + " is not an integer.");
};
module.exports.isArrayOf = function(expectedType, value, name) {
if (!Array.isArray(value))
throw new TypeError(name + " is not an array.");
if (!value.every(function(x) { return x instanceof expectedType; }))
throw new TypeError([name, " is not an array of ", expectedType, "."].join(""));
};