forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpick.js
28 lines (21 loc) · 781 Bytes
/
pick.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('pick', function() {
var obj = {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, 1: 7};
it('copies the named properties of an object to the new object', function() {
eq(R.pick(['a', 'c', 'f'], obj), {a: 1, c: 3, f: 6});
});
it('handles numbers as properties', function() {
eq(R.pick([1], obj), {1: 7});
});
it('ignores properties not included', function() {
eq(R.pick(['a', 'c', 'g'], obj), {a: 1, c: 3});
});
it('retrieves prototype properties', function() {
var F = function(param) {this.x = param;};
F.prototype.y = 40; F.prototype.z = 50;
var obj = new F(30);
obj.v = 10; obj.w = 20;
eq(R.pick(['w', 'x', 'y'], obj), {w: 20, x: 30, y: 40});
});
});