forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove.js
28 lines (22 loc) · 1.02 KB
/
remove.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
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
describe('remove', function() {
it('splices out a sub-list of the given list', function() {
var list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
eq(R.remove(2, 5, list), ['a', 'b', 'h', 'i', 'j']);
});
it('returns the appropriate sublist when start == 0', function() {
var list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
eq(R.remove(0, 5, list), ['f', 'g', 'h', 'i', 'j']);
eq(R.remove(0, 1, list), ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']);
eq(R.remove(0, list.length, list), []);
});
it('removes the end of the list if the count is too large', function() {
var list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
eq(R.remove(2, 20, list), ['a', 'b']);
});
it('retains the entire list if the start is too large', function() {
var list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
eq(R.remove(13, 3, list), ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']);
});
});