Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Mar 30, 2023
1 parent 4463e22 commit 1a253a2
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/block-editor/src/utils/test/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,44 @@ describe( 'immutableSet', () => {
} );
} );
} );

describe( 'for nested falsey values', () => {
it( 'overwrites undefined values', () => {
const result = immutableSet( { test: undefined }, 'test', 1 );

expect( result ).toEqual( { test: 1 } );
} );

it( 'overwrites null values', () => {
const result = immutableSet( { test: null }, 'test', 1 );

expect( result ).toEqual( { test: 1 } );
} );

it( 'overwrites false values', () => {
const result = immutableSet( { test: false }, 'test', 1 );

expect( result ).toEqual( { test: 1 } );
} );

it( 'overwrites `0` values', () => {
const result = immutableSet( { test: 0 }, 'test', 1 );

expect( result ).toEqual( { test: 1 } );
} );

it( 'overwrites empty string values', () => {
const result = immutableSet( { test: '' }, 'test', 1 );

expect( result ).toEqual( { test: 1 } );
} );

it( 'overwrites NaN values', () => {
const result = immutableSet( { test: NaN }, 'test', 1 );

expect( result ).toEqual( { test: 1 } );
} );
} );
} );

describe( 'does not mutate the original object', () => {
Expand Down

0 comments on commit 1a253a2

Please sign in to comment.