-
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.
UIU-2701: Return appropriate error message when item for manual fee/f…
…ine can't be found (#2847)
- Loading branch information
1 parent
7d0fc72
commit eedb997
Showing
9 changed files
with
397 additions
and
41 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
77 changes: 77 additions & 0 deletions
77
src/components/Accounts/ChargeFeeFine/ChargeFeeFine.test.js
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,77 @@ | ||
import { | ||
screen, | ||
render, | ||
} from '@folio/jest-config-stripes/testing-library/react'; | ||
import userEvent from '@folio/jest-config-stripes/testing-library/user-event'; | ||
|
||
import ChargeFeeFine from './ChargeFeeFine'; | ||
import ChargeForm from './ChargeForm'; | ||
|
||
const basicProps = { | ||
resources: { | ||
activeRecord: { | ||
isBarcodeValidated: true, | ||
}, | ||
}, | ||
mutator: { | ||
activeRecord: { | ||
update: jest.fn(), | ||
}, | ||
}, | ||
user: {}, | ||
stripes: {}, | ||
location: {}, | ||
history: {}, | ||
intl: {}, | ||
match: { | ||
params: {}, | ||
}, | ||
okapi: { | ||
currentUser: {}, | ||
}, | ||
}; | ||
const testIds = { | ||
selectItem: 'selectItem', | ||
}; | ||
const itemBarcode = 'itemBarcode'; | ||
|
||
jest.mock('./ChargeForm', () => jest.fn(({ | ||
onClickSelectItem, | ||
}) => ( | ||
<> | ||
<button | ||
type="button" | ||
data-testid={testIds.selectItem} | ||
onClick={() => onClickSelectItem(itemBarcode)} | ||
> | ||
Enter | ||
</button> | ||
</> | ||
))); | ||
jest.mock('./ItemLookup', () => jest.fn(() => <div />)); | ||
jest.mock('../Actions/ActionModal', () => jest.fn(() => <div />)); | ||
|
||
describe('ChargeFeeFine', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
beforeEach(() => { | ||
render(<ChargeFeeFine {...basicProps} />); | ||
}); | ||
|
||
it('should trigger ChargeForm', () => { | ||
expect(ChargeForm).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should update activeRecord', async () => { | ||
const selectItemButton = screen.getByTestId(testIds.selectItem); | ||
|
||
await userEvent.click(selectItemButton); | ||
|
||
expect(basicProps.mutator.activeRecord.update).toHaveBeenCalledWith({ | ||
barcode: itemBarcode, | ||
isBarcodeValidated: true, | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.