Skip to content

Commit

Permalink
Clear test mock to check it was not called
Browse files Browse the repository at this point in the history
  • Loading branch information
noahtallen committed Jul 20, 2020
1 parent 3d93afe commit a530aaf
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ describe( 'useBlockSync hook', () => {
{ clientId: 'b', innerBlocks: [], attributes: { foo: 1 } },
];

// Reset it so that we can test that it was not called after this point.
onChange1.mockReset();
const onChange2 = jest.fn();

// Update the component to point at a "different entity" (e.g. different
Expand All @@ -424,11 +426,8 @@ describe( 'useBlockSync hook', () => {
.dispatch( 'core/block-editor' )
.updateBlockAttributes( 'b', { foo: 3 } );

// The first callback should not be called with the new change.
expect( onChange1 ).toHaveBeenCalledWith( updatedBlocks1, {
selectionEnd: {},
selectionStart: {},
} );
// The first callback should not have been called.
expect( onChange1 ).not.toHaveBeenCalled();

// The second callback should be called with the new change.
expect( onChange2 ).toHaveBeenCalledWith(
Expand Down

0 comments on commit a530aaf

Please sign in to comment.