forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove.js
22 lines (19 loc) · 766 Bytes
/
move.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
var list = ['a', 'b', 'c', 'd', 'e', 'f'];
describe('move', function() {
it('moves an element from an index to another', function() {
eq(R.move(0, 1, list), ['b', 'a', 'c', 'd', 'e', 'f']);
eq(R.move(2, 1, list), ['a', 'c', 'b', 'd', 'e', 'f']);
eq(R.move(-1, 0, list), ['f', 'a', 'b', 'c', 'd', 'e']);
eq(R.move(0, -1, list), ['b', 'c', 'd', 'e', 'f', 'a']);
});
it('does nothing when indexes are outside the list outbounds', function() {
eq(R.move(-20, 2, list), list);
eq(R.move(20, 2, list), list);
eq(R.move(2, 20, list), list);
eq(R.move(2, -20, list), list);
eq(R.move(20, 20, list), list);
eq(R.move(-20, -20, list), list);
});
});