Skip to content

Commit 62bac00

Browse files
committed
Add tests to date validator
and improve func validator code styles
1 parent c323015 commit 62bac00

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

spec/validators/date.spec.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const valid = require('../../lib/validators/date');
2+
3+
const model = {
4+
date: true
5+
};
6+
7+
describe(' - Date validator', () => {
8+
9+
it('shall be a function', () => {
10+
expect(typeof valid).toEqual('function');
11+
});
12+
13+
it('shall return true with a valid date', () => {
14+
const date = new Date();
15+
const result = valid(date, model);
16+
expect(result).toEqual(true);
17+
});
18+
19+
it('shall return true with a parsable date', () => {
20+
const date = 'Jan 9, 2018';
21+
const result = valid(date, model);
22+
expect(result).toEqual(true);
23+
});
24+
25+
it('shall return false with a non parsable date', () => {
26+
const date = 'NoDate';
27+
const result = valid(date, model);
28+
expect(result).toEqual(false);
29+
});
30+
31+
});

spec/validators/func.spec.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
const valid = require('../../lib/validators/func');
22

3-
4-
5-
describe(' - Function validator', () => {
6-
7-
3+
describe(' - Function validator', () => {
84
it('shall be a function', () => {
95
expect(typeof valid).toEqual('function');
106
});

0 commit comments

Comments
 (0)