node-containerpattern
Advanced tools
Comparing version 0.3.2 to 0.4.0
@@ -6,19 +6,22 @@ | ||
const path = require("path"), | ||
const path = require("path"); | ||
gulp = require("gulp"), | ||
plumber = require("gulp-plumber"), | ||
// gulp | ||
const gulp = require("gulp"); | ||
const plumber = require("gulp-plumber"); | ||
eslint = require("gulp-eslint"), | ||
mocha = require("gulp-mocha"); | ||
// tests | ||
const eslint = require("gulp-eslint"); | ||
const mocha = require("gulp-mocha"); | ||
// compress | ||
const uglify = require("gulp-uglify"); | ||
// private | ||
var _gulpFile = path.join(__dirname, "gulpfile.js"), | ||
_libDir = path.join(__dirname, "lib"), | ||
_libFiles = path.join(_libDir, "*.js"), | ||
_distDir = path.join(__dirname, "dist"), | ||
_distFiles = path.join(_distDir, "*.js"), | ||
_unitTestsFiles = path.join(__dirname, "tests", "*.js"), | ||
_toTestFiles = [_gulpFile, _libFiles, _unitTestsFiles]; | ||
var _gulpFile = path.join(__dirname, "gulpfile.js"); | ||
var _libDir = path.join(__dirname, "lib"); | ||
var _libFiles = path.join(_libDir, "*.js"); | ||
var _unitTestsFiles = path.join(__dirname, "tests", "*.js"); | ||
var _toTestFiles = [_gulpFile, _libFiles, _unitTestsFiles]; | ||
@@ -25,0 +28,0 @@ // tasks |
@@ -7,2 +7,4 @@ | ||
var EMAIL_PATTERN = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | ||
var IPV4_PATTERN = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za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d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; | ||
@@ -25,3 +27,3 @@ // private | ||
if ("undefined" === typeof value) { | ||
throw new Error("The \"" + key + "\" value is undefined"); | ||
throw new ReferenceError("The \"" + key + "\" value is undefined"); | ||
} | ||
@@ -43,3 +45,3 @@ | ||
if ("string" !== typeof value) { | ||
throw new Error("The \"" + key + "\" data does not correspond to the skeleton"); | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
@@ -50,3 +52,3 @@ else if ("{" === value[0] && "}" === value[value.length-1]) { | ||
else { | ||
throw new Error("The \"" + key + "\" data does not correspond to the skeleton"); | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
@@ -62,3 +64,3 @@ | ||
if ("string" !== typeof value) { | ||
throw new Error("The \"" + key + "\" data does not correspond to the skeleton"); | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
@@ -69,3 +71,3 @@ else if ("[" === value[0] && "]" === value[value.length-1]) { | ||
else { | ||
throw new Error("The \"" + key + "\" data does not correspond to the skeleton"); | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
@@ -76,3 +78,3 @@ | ||
} | ||
else if (-1 < ["string", "email", "boolean", "number", "float", "integer"].indexOf(that.skeletons[key])) { | ||
else if (-1 < ["boolean", "email", "float", "integer", "ipv4", "ipv6", "number", "string"].indexOf(that.skeletons[key])) { | ||
@@ -90,6 +92,6 @@ if (that.skeletons[key] !== typeof value) { | ||
if ("string" !== typeof value) { | ||
throw new Error("The \"" + key + "\" data does not correspond to the skeleton"); | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
else if ("" !== value && !EMAIL_PATTERN.test(value)) { | ||
throw new Error("The \"" + key + "\" data does not correspond to the skeleton"); | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
@@ -99,2 +101,24 @@ | ||
case "ipv4": | ||
if ("string" !== typeof value) { | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
else if ("" !== value && !IPV4_PATTERN.test(value)) { | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
break; | ||
case "ipv6": | ||
if ("string" !== typeof value) { | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
else if ("" !== value && !IPV6_PATTERN.test(value)) { | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
break; | ||
case "boolean": | ||
@@ -107,3 +131,3 @@ value = ("true" === value || "yes" === value || "y" === value || "1" === value || 1 === value || true === value); | ||
if (isNaN(parseFloat(value))) { | ||
throw new Error("The \"" + key + "\" data does not correspond to the skeleton"); | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
@@ -118,3 +142,3 @@ else { | ||
if (isNaN(parseInt(value))) { | ||
throw new Error("The \"" + key + "\" data does not correspond to the skeleton"); | ||
throw new TypeError("The \"" + key + "\" data does not correspond to the skeleton"); | ||
} | ||
@@ -267,5 +291,8 @@ else { | ||
if ("string" !== typeof key) { | ||
throw new Error("The key is not a string"); | ||
if ("undefined" === typeof key) { | ||
throw new ReferenceError("The key does not exist"); | ||
} | ||
else if ("string" !== typeof key) { | ||
throw new TypeError("The key is not a string"); | ||
} | ||
else { | ||
@@ -301,9 +328,12 @@ | ||
bindSkeleton (key, skeleton) { | ||
skeleton (key, skeleton) { | ||
key = _formateKey(key); | ||
if ("string" !== typeof skeleton) { | ||
throw new Error("The \"" + key + "\" data has an invalid \"skeleton\" attribute"); | ||
if ("undefined" === typeof skeleton) { | ||
throw new ReferenceError("The \"" + key + "\" data has not any \"skeleton\" attribute"); | ||
} | ||
else if ("string" !== typeof skeleton) { | ||
throw new TypeError("The \"" + key + "\" data has an invalid \"skeleton\" attribute"); | ||
} | ||
else { | ||
@@ -313,4 +343,4 @@ | ||
if (-1 >= ["string", "email", "object", "array", "boolean", "integer", "float", "number"].indexOf(skeleton)) { | ||
throw new Error("The \"" + key + "\" data has an invalid \"skeleton\" attribute"); | ||
if (-1 >= ["array", "boolean", "email", "float", "integer", "ipv4", "ipv6", "number", "object", "string"].indexOf(skeleton)) { | ||
throw new TypeError("The \"" + key + "\" data has an invalid \"skeleton\" attribute"); | ||
} | ||
@@ -358,10 +388,10 @@ else { | ||
document (key, documentation) { | ||
key = _formateKey(key); | ||
if ("undefined" === typeof documentation) { | ||
throw new Error("The \"" + key + "\" documentation is undefined"); | ||
throw new ReferenceError("The \"" + key + "\" data has not any \"documentation\" attribute"); | ||
} | ||
else if ("string" !== typeof documentation) { | ||
throw new Error("The \"" + key + "\" documentation is not a string"); | ||
throw new TypeError("The \"" + key + "\" data has an invalid \"documentation\" attribute"); | ||
} | ||
@@ -449,5 +479,8 @@ else { | ||
if (!_isArray(limit)) { | ||
throw new Error("The \"" + key + "\" data has an invalid \"limit\" attribute"); | ||
if ("undefined" === typeof limit) { | ||
throw new ReferenceError("The \"" + key + "\" data has not any \"limit\" attribute"); | ||
} | ||
else if (!_isArray(limit)) { | ||
throw new TypeError("The \"" + key + "\" data has an invalid \"limit\" attribute"); | ||
} | ||
else { | ||
@@ -454,0 +487,0 @@ this.limits[key] = limit; |
{ | ||
"name": "node-containerpattern", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"description": "A 'Container pattern' object for a clean global use of data.", | ||
@@ -8,3 +8,3 @@ "main": "lib/main.js", | ||
"start": "node lib/main.js", | ||
"test": "npm update && gulp" | ||
"test": "npm update && gulp mocha" | ||
}, | ||
@@ -34,3 +34,3 @@ "repository": { | ||
"gulp-eslint": "^3.0.1", | ||
"gulp-mocha": "^3.0.1" | ||
"gulp-mocha": "^4.3.1" | ||
@@ -37,0 +37,0 @@ }, |
@@ -40,3 +40,2 @@ # node-containerpattern | ||
* ``` bindSkeleton(string key, string skeleton) : return this ``` skeleton must be "string", "email", "object", "array", "boolean", "integer", "float" or "number" | ||
* ``` clear() : return this ``` clearData & clearDocumentations & clearLimits & clearSkeletons | ||
@@ -54,2 +53,3 @@ * ``` clearData() : return this ``` forget all the keys and there values and documentations (=> Map.clear) | ||
* ``` set(string key, mixed value) : return this ``` associate and remember a key with a value (may be recursive) | ||
* ``` skeleton(string key, string skeleton) : return this ``` skeleton must be "array", "boolean", "email", "float", "integer", "ipv4", "ipv6", "number", "object", "string" | ||
@@ -68,6 +68,6 @@ -- notes -- | ||
container | ||
.bindSkeleton("contact", "email").document("contact", "Contact address") | ||
.bindSkeleton("debug", "boolean").document("debug", "This is the debug module") | ||
.bindSkeleton("vat", "float") | ||
.bindSkeleton("heigth", "integer") | ||
.skeleton("contact", "email").document("contact", "Contact address") | ||
.skeleton("debug", "boolean").document("debug", "This is the debug module") | ||
.skeleton("vat", "float") | ||
.skeleton("heigth", "integer") | ||
@@ -74,0 +74,0 @@ .set('contact', "myaddress@provider.com") |
@@ -5,4 +5,4 @@ "use strict"; | ||
const assert = require("assert"), | ||
Container = require(require("path").join(__dirname, "..", "lib", "main.js")); | ||
const assert = require("assert"); | ||
const Container = require(require("path").join(__dirname, "..", "lib", "main.js")); | ||
@@ -50,3 +50,3 @@ // private | ||
describe("bindSkeleton", () => { | ||
describe("skeleton", () => { | ||
@@ -57,19 +57,25 @@ before(() => { container.clear(); }); | ||
it("should check type value", () => { | ||
assert.throws(() => { container.bindSkeleton(false); }, Error, "check type value does not throw an error"); | ||
assert.throws(() => { container.bindSkeleton("testskeleton"); }, Error, "check type value does not throw an error"); | ||
assert.throws(() => { container.bindSkeleton("testskeleton", String); }, Error, "check type value does not throw an error"); | ||
assert.throws(() => { container.skeleton(false); }, Error, "check type value does not throw an error"); | ||
assert.throws(() => { container.skeleton("testskeleton"); }, Error, "check type value does not throw an error"); | ||
assert.throws(() => { container.skeleton("testskeleton", String); }, Error, "check type value does not throw an error"); | ||
}); | ||
it("should check normal running", () => { | ||
assert.strictEqual(true, container.bindSkeleton("testskeletonstring", "String") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.bindSkeleton("testskeletonemail", "email") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.bindSkeleton("testskeletonarray", "array") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.bindSkeleton("testskeletonobject", "object") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.bindSkeleton("testskeletonnumber", "number") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.bindSkeleton("testskeletonboolean", "boolean") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.bindSkeleton("testskeletonboolean.recursive", "boolean") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.bindSkeleton("testskeletoninteger", "integer") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.bindSkeleton("testskeletonfloat", "float") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletonarray", "Array") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletonarray", "array") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletonboolean", "boolean") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletonemail", "email") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletonfloat", "float") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletoninteger", "integer") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletonipv4", "ipv4") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletonipv6", "ipv6") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletonnumber", "number") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletonobject", "object") instanceof Container, "normal running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("testskeletonstring", "string") instanceof Container, "normal running has invalid return"); | ||
}); | ||
it("should check normal recursive running", () => { | ||
assert.strictEqual(true, container.skeleton("testskeletonrecursive.test", "string") instanceof Container, "normal running has invalid return"); | ||
}); | ||
}); | ||
@@ -84,3 +90,3 @@ | ||
assert.strictEqual(1, container.bindSkeleton("test", "string").set("test", "test", "This is a test").size, "initialized data size is invalid"); | ||
assert.strictEqual(1, container.skeleton("test", "string").set("test", "test", "This is a test").size, "initialized data size is invalid"); | ||
assert.strictEqual(1, Object.keys(container.skeletons).length, "initialized skeletons size is invalid"); | ||
@@ -124,5 +130,6 @@ assert.strictEqual(true, container.clearData() instanceof Container, "normal \"clearData\" running has invalid return"); | ||
it("should check type value", () => { | ||
assert.throws(() => { container.document(false); }, Error, "check type value does not throw an error"); | ||
assert.throws(() => { container.document("testdocument"); }, Error, "check type value does not throw an error"); | ||
assert.throws(() => { container.document("testdocument", String); }, Error, "check type value does not throw an error"); | ||
assert.throws(() => { container.document(); }, ReferenceError, "check type value does not throw an error"); | ||
assert.throws(() => { container.document(false); }, TypeError, "check type value does not throw an error"); | ||
assert.throws(() => { container.document("testdocument"); }, ReferenceError, "check type value does not throw an error"); | ||
assert.throws(() => { container.document("testdocument", false); }, TypeError, "check type value does not throw an error"); | ||
}); | ||
@@ -162,3 +169,3 @@ | ||
.bindSkeleton("testrecursivefloat.test", "float") | ||
.skeleton("testrecursivefloat.test", "float") | ||
.set("testrecursivefloat.test", 1.1, "This is a recursive test") | ||
@@ -219,3 +226,3 @@ .set("testrecursivefloat", { "test" : 1.1 }, "This is a recursive test"); | ||
it("should check normal formated boolean running", () => { | ||
assert.strictEqual(true, container.bindSkeleton("test", "boolean").set("test", "y").get("test"), "normal formated boolean running has invalid return"); | ||
assert.strictEqual(true, container.skeleton("test", "boolean").set("test", "y").get("test"), "normal formated boolean running has invalid return"); | ||
}); | ||
@@ -279,12 +286,14 @@ | ||
.bindSkeleton("testskeletonarray", "array") | ||
.bindSkeleton("testskeletonobject", "object") | ||
.bindSkeleton("testskeletonboolean", "boolean") | ||
.bindSkeleton("testskeletonbooleans", "object") | ||
.bindSkeleton("testskeletonbooleans.recursive", "boolean") | ||
.bindSkeleton("testskeletonstring", "string") | ||
.bindSkeleton("testskeletonemail", "email") | ||
.bindSkeleton("testskeletonnumber", "number") | ||
.bindSkeleton("testskeletoninteger", "integer") | ||
.bindSkeleton("testskeletonfloat", "float"); | ||
.skeleton("testskeletonarray", "array") | ||
.skeleton("testskeletonboolean", "boolean") | ||
.skeleton("testskeletonemail", "email") | ||
.skeleton("testskeletonfloat", "float") | ||
.skeleton("testskeletoninteger", "integer") | ||
.skeleton("testskeletonipv4", "ipv4") | ||
.skeleton("testskeletonipv6", "ipv6") | ||
.skeleton("testskeletonnumber", "number") | ||
.skeleton("testskeletonobject", "object") | ||
.skeleton("testskeletonbooleans", "object") | ||
.skeleton("testskeletonbooleans.recursive", "boolean") | ||
.skeleton("testskeletonstring", "string"); | ||
@@ -360,3 +369,3 @@ }); | ||
describe("string", () => { | ||
describe("array", () => { | ||
@@ -366,11 +375,11 @@ before(() => { container.clearData(); }); | ||
it("should check normal running with skeleton", () => { | ||
it("should check normal running with array skeleton", () => { | ||
assert.doesNotThrow(() => { container.set("testskeletonstring", ""); }, Error, "empty running with skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonstring", 5); }, Error, "numeric running with skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonstring", "5"); }, Error, "normal running with skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonarray", []); }, Error, "normal running with array skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonarray", [ "test", "test" ]); }, Error, "normal running with array skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonarray", "[\"test\", \"test2\"]"); }, Error, "normal running with array skeleton throws an error"); | ||
assert.strictEqual("5", container.get("testskeletonstring"), "normal running has invalid return"); | ||
assert.deepStrictEqual(["test", "test2"], container.get("testskeletonarray"), "normal running with array has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running with array has invalid size"); | ||
@@ -381,22 +390,2 @@ }); | ||
describe("email", () => { | ||
before(() => { container.clearData(); }); | ||
after(() => { container.clearData(); }); | ||
it("should check normal running with skeleton", () => { | ||
assert.doesNotThrow(() => { container.set("testskeletonemail", ""); }, Error, "empty running with skeleton throws an error"); | ||
assert.throws(() => { container.set("testskeletonemail", 5); }, Error, "wrong running with skeleton does not throw an error"); | ||
assert.throws(() => { container.set("testskeletonemail", "test"); }, Error, "wrong running with skeleton does not throw an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonemail", "myaddress@provider.com"); }, Error, "normal running with skeleton throws an error"); | ||
assert.strictEqual("myaddress@provider.com", container.get("testskeletonemail"), "normal running has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running has invalid return"); | ||
}); | ||
}); | ||
describe("boolean", () => { | ||
@@ -439,42 +428,58 @@ | ||
it("should check normal running with recursive boolean skeleton", () => { | ||
describe("email", () => { | ||
assert.doesNotThrow(() => { container.set("testskeletonbooleans.recursive", "y"); }, Error, "normal running with recursive boolean skeleton throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonbooleans.recursive"), "normal running with recursive boolean skeleton has invalid return"); | ||
before(() => { container.clearData(); }); | ||
after(() => { container.clearData(); }); | ||
assert.doesNotThrow(() => { container.set("testskeletonbooleans", { "recursive": "y"} ); }, Error, "normal running with recursive boolean skeleton throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonbooleans").recursive, "normal running with recursive boolean skeleton has invalid return"); | ||
it("should check normal running with skeleton", () => { | ||
assert.strictEqual(1, container.size, "normal running with recursive boolean skeleton has invalid return"); | ||
assert.doesNotThrow(() => { container.set("testskeletonemail", ""); }, Error, "empty running with skeleton throws an error"); | ||
assert.throws(() => { container.set("testskeletonemail", 5); }, Error, "wrong running with skeleton does not throw an error"); | ||
assert.throws(() => { container.set("testskeletonemail", "test"); }, Error, "wrong running with skeleton does not throw an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonemail", "myaddress@provider.com"); }, Error, "normal running with skeleton throws an error"); | ||
assert.strictEqual("myaddress@provider.com", container.get("testskeletonemail"), "normal running has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running has invalid return"); | ||
}); | ||
it("should check normal running with limited boolean skeleton", () => { | ||
}); | ||
assert.doesNotThrow(() => { container.limit("testskeletonboolean", [true, false]).set("testskeletonboolean", true); }, Error, "normal running with limited boolean skeleton throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonboolean"), "normal running with limited boolean skeleton has invalid return"); | ||
describe("ipv4", () => { | ||
assert.throws(() => { container.limit("testskeletonboolean", [true, false]).set("testskeletonboolean", "y"); }, Error, "normal running with limited boolean skeleton does not throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonboolean"), "normal running with limited boolean skeleton has invalid return"); | ||
before(() => { container.clearData(); }); | ||
after(() => { container.clearData(); }); | ||
assert.strictEqual(1, container.size, "normal running with limited boolean skeleton has invalid return"); | ||
it("should check normal running with skeleton", () => { | ||
assert.doesNotThrow(() => { container.set("testskeletonipv4", ""); }, Error, "empty running with skeleton throws an error"); | ||
assert.throws(() => { container.set("testskeletonipv4", 5); }, Error, "wrong running with skeleton does not throw an error"); | ||
assert.throws(() => { container.set("testskeletonipv4", "10.10"); }, Error, "wrong running with skeleton does not throw an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonipv4", "212.212.100.110"); }, Error, "normal running with skeleton throws an error"); | ||
assert.strictEqual("212.212.100.110", container.get("testskeletonipv4"), "normal running has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running has invalid return"); | ||
}); | ||
it("should check normal running with limited recursive boolean skeleton", () => { | ||
}); | ||
assert.doesNotThrow(() => { container.limit("testskeletonbooleans.recursive", [ true, false ]); }, Error, "normal running with limited recursive boolean skeleton throws an error"); | ||
describe("ipv6", () => { | ||
// check key recursivity | ||
assert.throws(() => { container.set("testskeletonbooleans.recursive", "y" ); }, Error, "normal running with limited recursive boolean skeleton does not throw an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonbooleans.recursive", true); }, Error, "normal running with limited recursive boolean skeleton throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonbooleans.recursive"), "normal running with limited recursive boolean skeleton return"); | ||
before(() => { container.clearData(); }); | ||
after(() => { container.clearData(); }); | ||
// check content recursivity | ||
assert.throws(() => { container.set("testskeletonbooleans", { "recursive": "y" } ); }, Error, "normal running with limited recursive boolean skeleton does not throw an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonbooleans", { "recursive": true } ); }, Error, "normal running with limited recursive boolean skeleton throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonbooleans").recursive, "normal running with limited recursive boolean skeleton has invalid return"); | ||
it("should check normal running with skeleton", () => { | ||
assert.strictEqual(1, container.size, "normal running with limited recursive boolean skeleton has invalid return"); | ||
assert.doesNotThrow(() => { container.set("testskeletonipv6", ""); }, Error, "empty running with skeleton throws an error"); | ||
assert.throws(() => { container.set("testskeletonipv6", 5); }, Error, "wrong running with skeleton does not throw an error"); | ||
assert.throws(() => { container.set("testskeletonipv6", "10.10"); }, Error, "wrong running with skeleton does not throw an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonipv6", "0000:0000:0000:0000:0000:0000:0000:0001"); }, Error, "normal running with skeleton throws an error"); | ||
assert.strictEqual("0000:0000:0000:0000:0000:0000:0000:0001", container.get("testskeletonipv6"), "normal running has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running has invalid return"); | ||
}); | ||
@@ -506,3 +511,3 @@ | ||
assert.strictEqual(2, container.size, "normal running with float has invalid size"); | ||
assert.strictEqual(1, container.size, "normal running with float has invalid size"); | ||
@@ -518,3 +523,3 @@ }); | ||
assert.strictEqual(3, container.size, "normal running with integer has invalid size"); | ||
assert.strictEqual(1, container.size, "normal running with integer has invalid size"); | ||
@@ -525,3 +530,3 @@ }); | ||
describe("array", () => { | ||
describe("object", () => { | ||
@@ -531,11 +536,11 @@ before(() => { container.clearData(); }); | ||
it("should check normal running with array skeleton", () => { | ||
it("should check normal running with object skeleton", () => { | ||
assert.doesNotThrow(() => { container.set("testskeletonarray", []); }, Error, "normal running with array skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonarray", [ "test", "test" ]); }, Error, "normal running with array skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonarray", "[\"test\", \"test2\"]"); }, Error, "normal running with array skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonobject", {}); }, Error, "normal running with object skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonobject", { "test": "test" }); }, Error, "normal running with object skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonobject", "{ \"test\": \"test\"}"); }, Error, "normal running with object skeleton throws an error"); | ||
assert.deepStrictEqual(["test", "test2"], container.get("testskeletonarray"), "normal running with array has invalid return"); | ||
assert.deepStrictEqual({ "test": "test"}, container.get("testskeletonobject"), "normal running with object skeleton has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running with array has invalid size"); | ||
assert.strictEqual(1, container.size, "normal running with object skeleton has invalid size"); | ||
@@ -546,3 +551,3 @@ }); | ||
describe("object", () => { | ||
describe("string", () => { | ||
@@ -552,11 +557,11 @@ before(() => { container.clearData(); }); | ||
it("should check normal running with object skeleton", () => { | ||
it("should check normal running with skeleton", () => { | ||
assert.doesNotThrow(() => { container.set("testskeletonobject", {}); }, Error, "normal running with object skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonobject", { "test": "test" }); }, Error, "normal running with object skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonobject", "{ \"test\": \"test\"}"); }, Error, "normal running with object skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonstring", ""); }, Error, "empty running with skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonstring", 5); }, Error, "numeric running with skeleton throws an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonstring", "5"); }, Error, "normal running with skeleton throws an error"); | ||
assert.deepStrictEqual({ "test": "test"}, container.get("testskeletonobject"), "normal running with object skeleton has invalid return"); | ||
assert.strictEqual("5", container.get("testskeletonstring"), "normal running has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running with object skeleton has invalid size"); | ||
assert.strictEqual(1, container.size, "normal running has invalid return"); | ||
@@ -567,4 +572,48 @@ }); | ||
it("should check normal running with recursive boolean skeleton", () => { | ||
assert.doesNotThrow(() => { container.set("testskeletonbooleans.recursive", "y"); }, Error, "normal running with recursive boolean skeleton throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonbooleans.recursive"), "normal running with recursive boolean skeleton has invalid return"); | ||
assert.doesNotThrow(() => { container.set("testskeletonbooleans", { "recursive": "y"} ); }, Error, "normal running with recursive boolean skeleton throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonbooleans").recursive, "normal running with recursive boolean skeleton has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running with recursive boolean skeleton has invalid return"); | ||
}); | ||
it("should check normal running with limited boolean skeleton", () => { | ||
assert.doesNotThrow(() => { container.limit("testskeletonboolean", [true, false]).set("testskeletonboolean", true); }, Error, "normal running with limited boolean skeleton throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonboolean"), "normal running with limited boolean skeleton has invalid return"); | ||
assert.throws(() => { container.limit("testskeletonboolean", [true, false]).set("testskeletonboolean", "y"); }, Error, "normal running with limited boolean skeleton does not throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonboolean"), "normal running with limited boolean skeleton has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running with limited boolean skeleton has invalid return"); | ||
}); | ||
it("should check normal running with limited recursive boolean skeleton", () => { | ||
assert.doesNotThrow(() => { container.limit("testskeletonbooleans.recursive", [ true, false ]); }, Error, "normal running with limited recursive boolean skeleton throws an error"); | ||
// check key recursivity | ||
assert.throws(() => { container.set("testskeletonbooleans.recursive", "y" ); }, Error, "normal running with limited recursive boolean skeleton does not throw an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonbooleans.recursive", true); }, Error, "normal running with limited recursive boolean skeleton throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonbooleans.recursive"), "normal running with limited recursive boolean skeleton return"); | ||
// check content recursivity | ||
assert.throws(() => { container.set("testskeletonbooleans", { "recursive": "y" } ); }, Error, "normal running with limited recursive boolean skeleton does not throw an error"); | ||
assert.doesNotThrow(() => { container.set("testskeletonbooleans", { "recursive": true } ); }, Error, "normal running with limited recursive boolean skeleton throws an error"); | ||
assert.strictEqual(true, container.get("testskeletonbooleans").recursive, "normal running with limited recursive boolean skeleton has invalid return"); | ||
assert.strictEqual(1, container.size, "normal running with limited recursive boolean skeleton has invalid return"); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56437
840