-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…183697) ## Summary Related to #7104 Extracted from #123748 `http2` headers are created via `Object.create(null)`, which causes issues with the way our `pick` method was implemented. PR fixes it.
- Loading branch information
1 parent
8a86be1
commit 4a3b74a
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { pick } from './pick'; | ||
|
||
describe('pick', () => { | ||
it('works with object created inline', () => { | ||
const obj = { foo: 'bar', hello: 'dolly' }; | ||
|
||
const result = pick(obj, ['foo']); | ||
expect(result).toEqual({ foo: 'bar' }); | ||
}); | ||
|
||
it('works with objects created via Object.create(null)', () => { | ||
const obj = Object.create(null); | ||
Object.assign(obj, { foo: 'bar', hello: 'dolly' }); | ||
|
||
const result = pick(obj, ['foo']); | ||
expect(result).toEqual({ foo: 'bar' }); | ||
}); | ||
|
||
it('does not pick properties from the prototype', () => { | ||
const proto = { prot: 'o' }; | ||
const obj = Object.create(proto); | ||
Object.assign(obj, { foo: 'bar', hello: 'dolly' }); | ||
|
||
const result = pick(obj, ['foo', 'prot']); | ||
expect(result).toEqual({ foo: 'bar' }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters