forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.js
31 lines (26 loc) · 908 Bytes
/
project.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 R = require('../source/index.js');
var eq = require('./shared/eq.js');
describe('project', function() {
var kids = [
{name: 'Abby', age: 7, hair: 'blond'},
{name: 'Fred', age: 12, hair: 'brown'},
{name: 'Rusty', age: 10, hair: 'brown'},
{name: 'Alois', age: 15, disposition: 'surly'}
];
it('selects the chosen properties from each element in a list', function() {
eq(R.project(['name', 'age'], kids), [
{name: 'Abby', age: 7},
{name: 'Fred', age: 12},
{name: 'Rusty', age: 10},
{name: 'Alois', age: 15}
]);
});
it('has an undefined property on the output tuple for any input tuple that does not have the property', function() {
eq(R.project(['name', 'hair'], kids), [
{name: 'Abby', hair: 'blond'},
{name: 'Fred', hair: 'brown'},
{name: 'Rusty', hair: 'brown'},
{name: 'Alois', hair: undefined}
]);
});
});