From a07f8ff1b2bc69cd885a8757da28630f19c89369 Mon Sep 17 00:00:00 2001 From: CodingCarlos Date: Sat, 14 Apr 2018 20:00:30 +0200 Subject: [PATCH] Update testcases to new modifier behaviour --- spec/modifiers/type.spec.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spec/modifiers/type.spec.js b/spec/modifiers/type.spec.js index 2d857d8..2c05e64 100644 --- a/spec/modifiers/type.spec.js +++ b/spec/modifiers/type.spec.js @@ -1,6 +1,6 @@ var valid = require('../../lib/modifiers/type'); -const str = 'Hello world'; +const str = '42'; const obj = {hello: 'world'}; const num = 42; const bool = true; @@ -29,20 +29,23 @@ describe(' - Type modifier', () => { for (let validType in typesKeys) { let model = {type: typesKeys[validType]}; for (let check in typesKeys) { + + // ToDo: ReWrite tests to clarify the behaviour in each use-case + it('shall only validate '+ typesKeys[validType] +' when model set, and '+ typesKeys[check] +' given', () => { const modelated = valid(types[typesKeys[check]], model); let shallBeValid = (typeof modelated === typesKeys[validType]); - if (typesKeys[validType] === 'object' && typeof modelated === 'undefined') { + if (typesKeys[validType] === 'object') { // && typeof modelated === 'undefined') { shallBeValid = true; } if ((typesKeys[validType] === 'array' && Array.isArray(modelated)) - || (typesKeys[validType] === 'array' && typeof modelated === 'undefined')) { + || (typesKeys[validType] === 'array')) { // && typeof modelated === 'undefined')) { shallBeValid = true; } - if (typesKeys[validType] === 'number' && typeof modelated === 'undefined') { + if (typesKeys[validType] === 'number') { // && typeof modelated === 'undefined') { shallBeValid = true; }