Skip to content

Commit 2920a26

Browse files
committed
Add test to default validation
1 parent af1e9b9 commit 2920a26

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

spec/modifiers/default.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var valid = require('../../lib/modifiers/default');
2+
3+
const model = {
4+
default: 'default value'
5+
};
6+
7+
describe(' - Default modifier', () => {
8+
it('shall be a function', () => {
9+
expect(typeof valid).toEqual('function');
10+
});
11+
12+
it('shall not modify data when no model set', () => {
13+
expect(valid('validData', {})).toEqual(null);
14+
expect(valid(undefined, {})).toEqual(null);
15+
});
16+
17+
it('shall not modify data if exists and model set', () => {
18+
expect(valid('validData', model)).toEqual(null);
19+
});
20+
21+
it('shall return the default value when not data and model set', () => {
22+
expect(valid(undefined, model)).toEqual(model.default);
23+
});
24+
});

0 commit comments

Comments
 (0)