-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathequalLength.test.js
39 lines (30 loc) · 1.29 KB
/
equalLength.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
'use strict';
const expect = require('chai').expect;
const validators = require('../src/common-validators');
describe('equalLength', function() {
it('empty is valid', function() {
expect(validators.equalLength(undefined, 5)).to.be.undefined;
});
it('number has zero length', function() {
expect(validators.equalLength(123456, 0)).to.be.undefined;
});
it('string has equal length', function() {
expect(validators.equalLength('12345', 5)).to.be.undefined;
});
it('string doesn\'t have equal length', function() {
expect(validators.equalLength('1234', 5)).to.have.property('error');
expect(validators.equalLength('123456', 5)).to.have.property('error');
});
it('unicode string is correct value', function() {
expect(validators.equalLength('\u0041\u0042\u0043\u0044\u0045', 5)).to.be.undefined;
});
it('array is correct value', function() {
expect(validators.equalLength([1,2,3,4,5], 5)).to.be.undefined;
});
it('array-like is correct value', function() {
expect(validators.equalLength({0: 'a', 1:'b', length: 5}, 5)).to.be.undefined;
});
it('object is correct value', function() {
expect(validators.equalLength({a: 1, b: 2, c: 3, d: 4, e: 5}, 5)).to.be.undefined;
});
});