Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Jan 14, 2025
1 parent 4ab5436 commit 2d696e7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ const bulkOperation = bulkEditLogsData[0];
const visibleColumns = [];
const setVisibleColumns = jest.fn();
const onKeepEditing = jest.fn();
const onPreviewSettled = jest.fn();

const defaultProps = {
open: true,
onKeepEditing,
isPreviewLoading: false,
onPreviewSettled,
isJobPreparing: false,
isPreviewSettled: false,
modalFooter: <div>Footer</div>,
};

Expand Down
18 changes: 18 additions & 0 deletions src/hooks/useConfirmChanges.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,22 @@ describe('useConfirmChanges', () => {
expect(result.current.isJobPreparing).toBe(false);
expect(result.current.isPreviewModalOpened).toBe(false); // Modal should close on error
});

it('should handle changePreviewSettled function correctly', async () => {
const { result, waitForNextUpdate } = renderHook(() => useConfirmChanges({
queryDownloadKey: 'testKey',
bulkOperationId: '123',
}));

// Call confirmChanges with a mock payload
act(() => {
result.current.changePreviewSettled(true);
});

expect(result.current.isPreviewSettled).toBe(false);

await waitForNextUpdate();

expect(result.current.isPreviewSettled).toBe(true);
});
});

0 comments on commit 2d696e7

Please sign in to comment.