forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrop.js
37 lines (27 loc) · 1009 Bytes
/
drop.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
var assert = require('assert');
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
describe('drop', function() {
it('skips the first `n` elements from a list, returning the remainder', function() {
eq(R.drop(3, ['a', 'b', 'c', 'd', 'e', 'f', 'g']), ['d', 'e', 'f', 'g']);
});
it('returns an empty array if `n` is too large', function() {
eq(R.drop(20, ['a', 'b', 'c', 'd', 'e', 'f', 'g']), []);
});
it('returns an equivalent list if `n` is <= 0', function() {
eq(R.drop(0, [1, 2, 3]), [1, 2, 3]);
eq(R.drop(-1, [1, 2, 3]), [1, 2, 3]);
eq(R.drop(-Infinity, [1, 2, 3]), [1, 2, 3]);
});
it('never returns the input array', function() {
var xs = [1, 2, 3];
assert.notStrictEqual(R.drop(0, xs), xs);
assert.notStrictEqual(R.drop(-1, xs), xs);
});
it('can operate on strings', function() {
eq(R.drop(3, 'Ramda'), 'da');
eq(R.drop(4, 'Ramda'), 'a');
eq(R.drop(5, 'Ramda'), '');
eq(R.drop(6, 'Ramda'), '');
});
});