diff --git a/src/views/ItemView.test.js b/src/views/ItemView.test.js index 96f092ecc..0ba7f42ef 100644 --- a/src/views/ItemView.test.js +++ b/src/views/ItemView.test.js @@ -379,7 +379,39 @@ describe('ItemView', () => { describe('when an error was occured', () => { 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(, 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 the record 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(, translationsProperties);