Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIIN-3195: Add and fix tests
Browse files Browse the repository at this point in the history
OleksandrHladchenko1 committed Jan 22, 2025
1 parent 29147ab commit b57210b
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/views/ItemView.test.js
Original file line number Diff line number Diff line change
@@ -376,10 +376,42 @@ describe('ItemView', () => {
expect(screen.queryByText('Linked order line')).not.toBeInTheDocument();
});

describe('when an error was occured', () => {
describe('when error was occured due to local-specific reference data', () => {
it('should show an error message', async () => {
useHoldingMutation.mockClear().mockReturnValue({ mutateHolding: mockMutate });
useUpdateOwnership.mockClear().mockReturnValue({ updateOwnership: jest.fn().mockRejectedValue() });
useUpdateOwnership.mockClear().mockReturnValue({
updateOwnership: jest.fn().mockRejectedValue({
response: {
status: 400,
}
})
});
checkIfUserInCentralTenant.mockClear().mockReturnValue(false);

renderWithIntl(<ItemViewSetup />, translationsProperties);

const updateOwnershipBtn = screen.getByText('Update ownership');
fireEvent.click(updateOwnershipBtn);

act(() => UpdateItemOwnershipModal.mock.calls[0][0].handleSubmit('university', { id: 'locationId' }, 'holdingId'));

const confirmationModal = screen.getByText('Update ownership of items');
fireEvent.click(within(confirmationModal).getByText('confirm'));

await waitFor(() => expect(screen.queryByText('Item ownership could not be updated because it contains local-specific reference data.')).toBeDefined());
});
});

describe('when error was occured', () => {
it('should show an error message', async () => {
useHoldingMutation.mockClear().mockReturnValue({ mutateHolding: mockMutate });
useUpdateOwnership.mockClear().mockReturnValue({
updateOwnership: jest.fn().mockRejectedValue({
response: {
status: 500,
},
})
});
checkIfUserInCentralTenant.mockClear().mockReturnValue(false);

renderWithIntl(<ItemViewSetup />, translationsProperties);

0 comments on commit b57210b

Please sign in to comment.