forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvaluesIn.js
39 lines (33 loc) · 1.19 KB
/
valuesIn.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
38
39
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
describe('valuesIn', function() {
var obj = {a: 100, b: [1, 2, 3], c: {x: 200, y: 300}, d: 'D', e: null, f: undefined};
function C() { this.a = 100; this.b = 200; }
C.prototype.x = function() { return 'x'; };
C.prototype.y = 'y';
var cobj = new C();
it("returns an array of the given object's values", function() {
var vs = R.valuesIn(obj);
eq(vs.length, 6);
eq(R.indexOf(100, vs) >= 0, true);
eq(R.indexOf('D', vs) >= 0, true);
eq(R.indexOf(null, vs) >= 0, true);
eq(R.indexOf(undefined, vs) >= 0, true);
eq(R.indexOf(obj.b, vs) >= 0, true);
eq(R.indexOf(obj.c, vs) >= 0, true);
});
it("includes the given object's prototype properties", function() {
var vs = R.valuesIn(cobj);
eq(vs.length, 4);
eq(R.indexOf(100, vs) >= 0, true);
eq(R.indexOf(200, vs) >= 0, true);
eq(R.indexOf(cobj.x, vs) >= 0, true);
eq(R.indexOf('y', vs) >= 0, true);
});
it('works for primitives', function() {
var result = R.map(function(val) {
return R.valuesIn(val);
}, [null, undefined, 55, '', true, false, NaN, Infinity, , []]);
eq(result, R.repeat([], 10));
});
});