-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
49 lines (44 loc) · 1.38 KB
/
test.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
40
41
42
43
44
45
46
47
48
49
/*!
* object.pluck <https://github.com/jonschlinkert/object.pluck>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT License
*/
'use strict';
var should = require('should');
var pluck = require('./');
describe('pluck', function() {
it('should pluck properties from the source object.', function () {
var fixture = {
a: {
aaa : 'foo',
bbb : 'alpha'
},
b: {
aaa : 'bar',
bbb : 'beta'
},
c: {
aaa : 'baz',
bbb : 'gamma'
}
};
pluck(fixture, 'aaa').should.eql({a: 'foo', b: 'bar', c: 'baz'});
pluck(fixture, 'bbb').should.eql({a: 'alpha', b: 'beta', c: 'gamma'});
});
it('should pluck properties from the source object.', function () {
var fixture = {
a: {locals : {first: 'Brian'}, options : {foo: true}},
b: {locals : {last: 'Woodward'}, options : {bar: false}}
};
pluck(fixture, 'locals').should.eql({a: {first: 'Brian'}, b: {last: 'Woodward'}});
pluck(fixture, 'options').should.eql({a: {foo: true}, b: {bar: false}});
});
it('should use property paths to get nested values from the source object.', function () {
var fixture = {
a: {locals : {name: {first: 'Brian'}}},
b: {locals : {name: {last: 'Woodward'}}}
};
pluck(fixture, 'locals.name').should.eql({a: {first: 'Brian'}, b: {last: 'Woodward'}});
});
});