Skip to content

Commit

Permalink
Adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Sep 1, 2021
1 parent 7a4eb7b commit 7670420
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions packages/core-data/src/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ describe( 'deleteEntityRecord', () => {
{ name: 'post', kind: 'postType', baseURL: '/wp/v2/posts' },
];

const dispatch = jest.fn();
const dispatch = Object.assign( jest.fn(), {
receiveEntityRecords: jest.fn(),
__unstableAcquireStoreLock: jest.fn(),
__unstableReleaseStoreLock: jest.fn(),
} );
// Provide entities
dispatch.mockReturnValueOnce( entities );

Expand All @@ -79,31 +83,26 @@ describe( 'deleteEntityRecord', () => {
method: 'DELETE',
} );


expect( dispatch ).toHaveBeenCalledTimes( 6 );
expect( dispatch ).toHaveBeenCalledTimes( 4 );
expect( dispatch ).toHaveBeenCalledWith( {
type: 'DELETE_ENTITY_RECORD_START',
kind: 'postType',
name: 'post',
recordId: 10,
} );
expect( dispatch ).toHaveBeenCalledWith( [
{
type: 'MOCKED_ACQUIRE_LOCK',
},
] );
expect( dispatch ).toHaveBeenCalledWith( {
type: 'DELETE_ENTITY_RECORD_FINISH',
kind: 'postType',
name: 'post',
recordId: 10,
error: undefined,
} );
expect( dispatch ).toHaveBeenCalledWith( [
{
type: 'MOCKED_RELEASE_LOCK',
},
] );
expect( dispatch.__unstableAcquireStoreLock ).toHaveBeenCalledTimes(
1
);
expect( dispatch.__unstableReleaseStoreLock ).toHaveBeenCalledTimes(
1
);

expect( result ).toBe( deletedRecord );
} );
Expand Down

0 comments on commit 7670420

Please sign in to comment.