-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
30 lines (23 loc) · 892 Bytes
/
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
import test from 'ava';
import colsFromArray from '.';
test('Should throw if args invalid', t => {
t.throws(() => {
colsFromArray('string');
}, TypeError);
t.throws(() => {
colsFromArray([1, 2], {colLength: '2'});
}, TypeError);
t.throws(() => {
colsFromArray([1], {colLength: 2});
}, Error);
});
test('Should convert array into cols', t => {
t.is(colsFromArray([1, 2, 3, 4]).length, 2);
t.is(colsFromArray([1, 2, 3, 4, 5, 6], {colLength: 3}).length, 3);
t.is(colsFromArray([1, 2, 3, 4, 5, 6, 7], {colLength: 3, fillCol: 0}).length, 3);
});
test('Should fill the cols to make array even when fillCol is not undefined', t => {
t.is(colsFromArray([1, 2, 3, 4, 5, 6, 7], {colLength: 3, fillCol: 0})[2].length, 3);
t.is(colsFromArray([1, 2, 3, 4, 5, 6, 7], {colLength: 2})[1].length, 3);
console.log(colsFromArray([1, 2, 3, 4, 5, 6, 7], {colLength: 3, fillCol: 0}));
});