Skip to content

Commit

Permalink
Add test for arrays being completely equal (#117)
Browse files Browse the repository at this point in the history
* Add test for arrays being completely equal

It's a nearly useless test, but it does get is-shallow-equal to 100% test coverage
See https://codecov.io/gh/WordPress/packages/src/master/packages/is-shallow-equal/index.js#L48 for the one piece of code not currently tested.

* fix spacing

* add test for object copies
  • Loading branch information
aaronjorbin authored and aduth committed Apr 30, 2018
1 parent fdc7f0b commit ee842ec
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/is-shallow-equal/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ describe( 'isShallowEqual', () => {
expect( isShallowEqual( obj, obj ) ).toBe( true );
} );

it( 'returns true on objects that are a copy of each other', () => {
const a = { foo: 1 };
const b = a;

expect( isShallowEqual( a, b ) ).toBe( true );
} );

it( 'returns true on object deep-but-referentially-equal values', () => {
const obj = {};
const a = { foo: obj };
Expand Down Expand Up @@ -104,6 +111,13 @@ describe( 'isShallowEqual', () => {

expect( isShallowEqual( a, b ) ).toBe( true );
} );

it( 'returns true on arrays that are a copy of each other', () => {
const a = [];
const b = a;

expect( isShallowEqual( a, b ) ).toBe( true );
} );
} );

describe( 'isShallowEqualArrays', () => {
Expand Down

0 comments on commit ee842ec

Please sign in to comment.