forked from angus-c/just
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (36 loc) · 795 Bytes
/
Copy pathindex.js
File metadata and controls
39 lines (36 loc) · 795 Bytes
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
var test = require('../util/test')(__filename);
var tail = require('../../packages/array-tail');
test('non empty arrays return all but head', function(t) {
t.plan(4);
var testArrays = [
[1, 2, 3, 4, 5],
[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
[{a: 1}, {b: 2}, {c: 3}, {d: 4}],
['a', 1, true, /r/g],
];
testArrays.forEach(function(arr) {
t.deepEqual(tail(arr), arr.slice(1));
});
t.end();
});
test('empty arrays return an empty array', function(t) {
t.plan(1);
t.deepEqual(tail([]), []);
t.end();
});
test('non-array arguments throw', function(t) {
t.plan(4);
t.throws(function() {
tail({});
});
t.throws(function() {
tail(undefined);
});
t.throws(function() {
tail(null);
});
t.throws(function() {
tail();
});
t.end();
});