Skip to content

Commit

Permalink
Update testcases to new modifier behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingCarlos committed Apr 14, 2018
1 parent 7106ec2 commit a07f8ff
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions spec/modifiers/type.spec.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit a07f8ff

Please sign in to comment.