UNPKG

897 BJavaScriptView Raw
1/*!
2 * object.pick <https://github.com/jonschlinkert/object.pick>
3 *
4 * Copyright (c) 2014 Jon Schlinkert, contributors.
5 * Licensed under the MIT License
6 */
7
8'use strict';
9
10var should = require('should');
11var pick = require('./');
12
13describe('.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});