|
| 1 | +const valid = require('../../lib/validators/value'); |
| 2 | + |
| 3 | +const str = 'Hello world'; |
| 4 | +// const obj = {hello: 'world'}; |
| 5 | +const num = 42; |
| 6 | +const bool = true; |
| 7 | + |
| 8 | +const types = { |
| 9 | + string: str, |
| 10 | + // object: obj, |
| 11 | + number: num |
| 12 | +}; |
| 13 | +const typesKeys = Object.keys(types); |
| 14 | + |
| 15 | +describe(' - Date validator', () => { |
| 16 | + |
| 17 | + it('shall be a function', () => { |
| 18 | + expect(typeof valid).toEqual('function'); |
| 19 | + }); |
| 20 | + |
| 21 | + describe('no filter specified', () => { |
| 22 | + const model = { |
| 23 | + value: {} |
| 24 | + }; |
| 25 | + |
| 26 | + for (let key in typesKeys) { |
| 27 | + it('shall validate ' + typesKeys[key], () => { |
| 28 | + expect(valid(types[key], model)).toEqual(true); |
| 29 | + }); |
| 30 | + } |
| 31 | + }); |
| 32 | + |
| 33 | + describe('equal filter', () => { |
| 34 | + |
| 35 | + // Again the for loop here! ^^ |
| 36 | + for (let validType in typesKeys) { |
| 37 | + describe('type ' + typesKeys[validType], () => { |
| 38 | + const model = { |
| 39 | + value: {} |
| 40 | + }; |
| 41 | + |
| 42 | + beforeEach(function () { |
| 43 | + model.value = { |
| 44 | + eq: types[typesKeys[validType]] |
| 45 | + }; |
| 46 | + }); |
| 47 | + |
| 48 | + for (let check in typesKeys) { |
| 49 | + it('shall not be equal than ' + typesKeys[check], () => { |
| 50 | + expect(valid(types[typesKeys[check]], model)).toEqual( (validType === check) ); |
| 51 | + }); |
| 52 | + } |
| 53 | + }); |
| 54 | + } |
| 55 | + }); |
| 56 | + |
| 57 | + describe('max filter', () => { |
| 58 | + // ToDo: TEST MAX FILTER |
| 59 | + }); |
| 60 | + |
| 61 | + describe('min filter', () => { |
| 62 | + // ToDo: TEST MIN FILTER |
| 63 | + }); |
| 64 | + |
| 65 | + describe('contains filter', () => { |
| 66 | + // ToDo: TEST CONTAINS FILTER |
| 67 | + }); |
| 68 | + |
| 69 | +}); |
0 commit comments