|
1 | 1 | var assert = require('assert') |
2 | | -var validate = require('../index') |
| 2 | +const bvec = require('../validators/bvec/bvec') |
3 | 3 |
|
4 | 4 | describe('bvec', function() { |
5 | 5 | it('should allow valid bvec contents', function() { |
6 | | - var bvec = '4 6 2 5\n3 2 3 5\n6 4 3 5' |
7 | | - validate.bvec({}, bvec, function(issues) { |
| 6 | + const vec = '4 6 2 5\n3 2 3 5\n6 4 3 5' |
| 7 | + bvec({}, vec, function(issues) { |
8 | 8 | assert.deepEqual(issues, []) |
9 | 9 | }) |
10 | 10 | }) |
11 | 11 |
|
12 | 12 | it('should not allow more or less than 3 rows', function() { |
13 | | - var bvec = '0 4 3 6 1 6 2 4\n 4 3 5 2 4 2 4 5' |
14 | | - validate.bvec({}, bvec, function(issues) { |
| 13 | + let vec = '0 4 3 6 1 6 2 4\n 4 3 5 2 4 2 4 5' |
| 14 | + bvec({}, vec, function(issues) { |
15 | 15 | assert(issues.length == 1 && issues[0].code == 31) |
16 | 16 | }) |
17 | 17 |
|
18 | | - bvec = |
| 18 | + vec = |
19 | 19 | '0 4 3 6 1 6 2 4\n 4 3 5 2 4 2 4 5\n 4 3 5 2 4 2 4 5\n 4 3 5 2 4 2 4 5' |
20 | | - validate.bvec({}, bvec, function(issues) { |
| 20 | + bvec({}, vec, function(issues) { |
21 | 21 | assert(issues.length == 1 && issues[0].code == 31) |
22 | 22 | }) |
23 | 23 | }) |
24 | 24 |
|
25 | 25 | it('should not allow rows of inconsistent length', function() { |
26 | | - var bvec = '0 4 3 6 1 6 4\n 4 3 4 2 4 5\n 4 3 5 2 4 2 4 5' |
27 | | - validate.bvec({}, bvec, function(issues) { |
| 26 | + const vec = '0 4 3 6 1 6 4\n 4 3 4 2 4 5\n 4 3 5 2 4 2 4 5' |
| 27 | + bvec({}, vec, function(issues) { |
28 | 28 | assert(issues.length == 1 && issues[0].code == 46) |
29 | 29 | }) |
30 | 30 | }) |
31 | 31 |
|
32 | 32 | it('should catch doublespace separators', function() { |
33 | | - var bvec = '4 6 2 5\n3 2 3 5\n6 4 3 5' |
34 | | - validate.bvec({}, bvec, function(issues) { |
| 33 | + const vec = '4 6 2 5\n3 2 3 5\n6 4 3 5' |
| 34 | + bvec({}, vec, function(issues) { |
35 | 35 | assert(issues.length == 1 && issues[0].code == 47) |
36 | 36 | }) |
37 | 37 | }) |
38 | 38 |
|
39 | 39 | it('should not allow undefined bvecs', function() { |
40 | | - const bvec = undefined |
41 | | - validate.bvec({}, bvec, function(issues) { |
| 40 | + const vec = undefined |
| 41 | + bvec({}, vec, function(issues) { |
42 | 42 | assert(issues.length == 1 && issues[0].code == 88) |
43 | 43 | }) |
44 | 44 | }) |
45 | 45 |
|
46 | 46 | it('should not allow bvecs of types other than string', function() { |
47 | | - const bvec = [0, 1, 2, 3] |
48 | | - validate.bvec({}, bvec, function(issues) { |
| 47 | + const vec = [0, 1, 2, 3] |
| 48 | + bvec({}, vec, function(issues) { |
49 | 49 | assert(issues.length == 1 && issues[0].code == 88) |
50 | 50 | }) |
51 | 51 | }) |
52 | 52 |
|
53 | 53 | it('should not allow bvals to be submitted in place of bvec', function() { |
54 | | - const bval = '4 6 7' |
55 | | - validate.bvec({}, bval, function(issues) { |
| 54 | + const vec = '4 6 7' |
| 55 | + bvec({}, vec, function(issues) { |
56 | 56 | assert(issues.length == 1 && issues[0].code == 31) |
57 | 57 | }) |
58 | 58 | }) |
|
0 commit comments