-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* UICIRC-1077: Allow override for reminder fees with renewal blocked (#2674) * UICIRC-1077: Allow override for reminder fees with renewal blocked * Cleanup * Add tests * Cleanup * Release 10.1.1 --------- Co-authored-by: Michał Kuklis <[email protected]>
- Loading branch information
1 parent
0478d59
commit feb4cce
Showing
6 changed files
with
92 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import { render, screen, waitFor } from '@folio/jest-config-stripes/testing-library/react'; | ||
import userEvent from '@folio/jest-config-stripes/testing-library/user-event'; | ||
|
||
import '__mock__/currencyData.mock'; | ||
import '__mock__/stripesCore.mock'; | ||
import '__mock__/intl.mock'; | ||
import buildStripes from '__mock__/stripes.mock'; | ||
import withRenew from './withRenew'; | ||
|
||
const BulkRenewalDialogMock = ({ errorMessages }) => { | ||
return <div>{errorMessages?.[1]?.props?.values?.message ?? ''}</div>; | ||
}; | ||
|
||
jest.mock('../BulkRenewalDialog', () => BulkRenewalDialogMock); | ||
|
||
const mutator = { | ||
loanPolicies: { | ||
GET: jest.fn(), | ||
reset: jest.fn(), | ||
}, | ||
renew: { | ||
POST: jest.fn().mockReturnValue(Promise.resolve()), | ||
}, | ||
requests: { | ||
GET: jest.fn().mockReturnValue(Promise.resolve()), | ||
reset: jest.fn(), | ||
}, | ||
}; | ||
|
||
const props = { | ||
mutator, | ||
intl: { formatMessage: ({ id }) => id }, | ||
stripes: buildStripes({ connect: (Component) => Component }), | ||
}; | ||
|
||
const Wrapper = ({ renew }) => ( | ||
<button type="button" onClick={() => renew([{ id: 1, reminders: { renewalBlocked: true } }], { barcode: '123' })}>Renew</button> | ||
); | ||
const WrappedComponent = withRenew(Wrapper); | ||
const renderWithRenew = (extraProps = {}) => render(<WrappedComponent {...props} {...extraProps} />); | ||
|
||
describe('withRenew', () => { | ||
it('should renew loans', async () => { | ||
renderWithRenew(); | ||
userEvent.click(screen.getByText('Renew')); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText('ui-users.errors.renewWithReminders')).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters