1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | 'use strict';
|
9 |
|
10 | var should = require('should');
|
11 | var pick = require('./');
|
12 |
|
13 | describe('.pick()', function () {
|
14 | it('should pick keys specified as strings.', function () {
|
15 | pick({a: 'a', b: 'b'}, 'a').should.eql({a: 'a'});
|
16 | });
|
17 |
|
18 | it('should pick keys specified as arrays.', function () {
|
19 | pick({a: 'a', b: 'b', c: 'c'}, ['a', 'b']).should.eql({a: 'a', b: 'b'});
|
20 | pick({foo: 'foo', bar: 'bar', baz: 'baz'}, ['foo', 'bar']).should.eql({foo: 'foo', bar: 'bar'});
|
21 | });
|
22 |
|
23 | it('should ignore keys that don\'t exist.', function () {
|
24 | pick({a: 'a', b: 'b', c: 'c'}, ['a', 'b', 'foo']).should.eql({a: 'a', b: 'b'});
|
25 | pick({foo: 'foo', bar: 'bar', baz: 'baz'}, ['foo', 'bar', 'abc']).should.eql({foo: 'foo', bar: 'bar'});
|
26 | });
|
27 | });
|