Skip to content

Commit

Permalink
replace getObjectEntries with Object.entries
Browse files Browse the repository at this point in the history
  • Loading branch information
d7my11 committed Nov 23, 2019
1 parent 2c3a862 commit 416f5b3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 23 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@
- `[jest-runtime]` Fix virtual mocks not being unmockable after previously being mocked ([#8396](https://github.com/facebook/jest/pull/8396))
- `[jest-transform]` Replace special characters in transform cache filenames to support Windows ([#8353](https://github.com/facebook/jest/pull/8353))
- `[jest-config]` Allow exactly one project ([#7498](https://github.com/facebook/jest/pull/7498))
>>>>>>> d74da1a0dde8f17997022f40a4adc07823d50c69

### Chore & Maintenance

Expand Down
13 changes: 0 additions & 13 deletions packages/expect/src/__tests__/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
const {stringify} = require('jest-matcher-utils');
const {
emptyObject,
getObjectEntries,
getObjectSubset,
getPath,
hasOwnProperty,
Expand Down Expand Up @@ -276,18 +275,6 @@ describe('getObjectSubset', () => {
});
});

describe('getObjectEntries', () => {
test('returns an empty array when called with null', () => {
expect(getObjectEntries(null)).toEqual([]);
});
test('returns an empty array when called with undefined', () => {
expect(getObjectEntries(undefined)).toEqual([]);
});
test('returns object entries', () => {
expect(getObjectEntries({a: 1, b: 2})).toEqual([['a', 1], ['b', 2]]);
});
});

describe('emptyObject()', () => {
test('matches an empty object', () => {
expect(emptyObject({})).toBe(true);
Expand Down
11 changes: 2 additions & 9 deletions packages/expect/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@ export const getObjectSubset = (
return object;
};

// NOTE: Should be removed after dropping node@6.x support,
// and we should use (Object.entries)
export const getObjectEntries: typeof Object.entries = (
object: any,
): Array<[string, any]> =>
object == null ? [] : Object.keys(object).map(key => [key, object[key]]);

const IteratorSymbol = Symbol.iterator;

const hasIterator = (object: any) =>
Expand Down Expand Up @@ -267,8 +260,8 @@ export const iterableEquality = (
return false;
}

const aEntries = getObjectEntries(a);
const bEntries = getObjectEntries(b);
const aEntries = Object.entries(a);
const bEntries = Object.entries(b);
if (!equals(aEntries, bEntries)) {
return false;
}
Expand Down

0 comments on commit 416f5b3

Please sign in to comment.