-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmin.test.js
32 lines (25 loc) · 1 KB
/
min.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const expect = require('chai').expect;
const validators = require('../src/common-validators');
describe('min', function() {
it('empty is valid', function() {
expect(validators.min(undefined, 5)).to.be.undefined;
});
it('not number is invalid', function() {
expect(validators.min('abc', 5)).to.have.property('error');
expect(validators.min({a: 1}, 5)).to.have.property('error');
expect(validators.min([1,2,3], 5)).to.have.property('error');
});
it('number more then min is valid', function() {
expect(validators.min(6, 5)).to.be.undefined;
});
it('number less then min is invalid', function() {
expect(validators.min(4, 5)).to.have.property('error');
});
it('number equal min is valid', function() {
expect(validators.min(5, 5)).to.be.undefined;
});
it('number equal min is invalid if exclusive=true', function() {
expect(validators.min(5, 5, {exclusive: true})).to.have.property('error');
});
});