-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotEmpty.test.js
55 lines (41 loc) · 1.5 KB
/
notEmpty.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
const expect = require('chai').expect;
const validators = require('../src/common-validators');
describe('notEmpty', function() {
it('true is valid', function() {
expect(validators.notEmpty(true)).to.be.undefined;
});
it('false is valid', function() {
expect(validators.notEmpty(false)).to.be.undefined;
});
it('string is valid', function() {
expect(validators.notEmpty('str')).to.be.undefined;
});
it('zero is valid', function() {
expect(validators.notEmpty(0)).to.be.undefined;
});
it('number is valid', function() {
expect(validators.notEmpty(1)).to.be.undefined;
});
it('full object is valid', function() {
expect(validators.notEmpty({a: 1})).to.be.undefined;
});
it('full array is valid', function() {
expect(validators.notEmpty([1])).to.be.undefined;
});
it('undefined is valid', function() {
expect(validators.notEmpty(undefined)).to.be.undefined;
});
it('null is invalid', function() {
expect(validators.notEmpty(null)).to.have.property('error');
});
it('empty string (or string with only spases) is invalid', function() {
expect(validators.notEmpty(' ')).to.have.property('error');
});
it('empy object is invalid', function() {
expect(validators.notEmpty({})).to.have.property('error');
});
it('empty array is invalid', function() {
expect(validators.notEmpty([])).to.have.property('error');
});
});