Skip to content

Commit 50a9941

Browse files
committed
Start value validator testing
Only eq filter. Need to test max, min and contains.
1 parent 62bac00 commit 50a9941

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

spec/validators/type.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const types = {
99
object: obj,
1010
number: num
1111
};
12-
1312
const typesKeys = Object.keys(types);
1413

1514
describe(' - Type validator', () => {

spec/validators/value.spec.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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

Comments
 (0)