forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
31 lines (23 loc) · 779 Bytes
/
init.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
var assert = require('assert');
var R = require('..');
var eq = require('./shared/eq');
describe('init', function() {
it('returns all but the last element of an ordered collection', function() {
eq(R.init([1, 2, 3]), [1, 2]);
eq(R.init([2, 3]), [2]);
eq(R.init([3]), []);
eq(R.init([]), []);
eq(R.init('abc'), 'ab');
eq(R.init('bc'), 'b');
eq(R.init('c'), '');
eq(R.init(''), '');
});
it('throws if applied to null or undefined', function() {
assert.throws(function() { R.init(null); }, TypeError);
assert.throws(function() { R.init(undefined); }, TypeError);
});
it('handles array-like object', function() {
var args = (function() { return arguments; }(1, 2, 3, 4, 5));
eq(R.init(args), [1, 2, 3, 4]);
});
});