-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIORGS-346 Add test for categories settings
- Loading branch information
1 parent
6cad28b
commit dd3790f
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
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,51 @@ | ||
import { render } from '@testing-library/react'; | ||
|
||
import { ControlledVocab } from '@folio/stripes/smart-components'; | ||
|
||
import CategorySettings from './CategorySettings'; | ||
|
||
jest.mock('@folio/stripes-smart-components/lib/ControlledVocab', () => jest.fn(({ | ||
rowFilter, | ||
label, | ||
rowFilterFunction, | ||
preCreateHook, | ||
listSuppressor, | ||
}) => ( | ||
<> | ||
{label} | ||
<div onChange={rowFilterFunction}>{rowFilter}</div> | ||
<button | ||
data-testid="button-new" | ||
type="button" | ||
onClick={() => { | ||
preCreateHook(); | ||
listSuppressor(); | ||
}} | ||
> | ||
New | ||
</button> | ||
</> | ||
))); | ||
|
||
const stripesMock = { | ||
connect: component => component, | ||
hasPerm: jest.fn(() => true), | ||
}; | ||
|
||
const renderCategorySettings = () => render( | ||
<CategorySettings | ||
stripes={stripesMock} | ||
/>, | ||
); | ||
|
||
describe('CategorySettings', () => { | ||
it('should check action suppression', () => { | ||
renderCategorySettings(); | ||
|
||
const { actionSuppressor } = ControlledVocab.mock.calls[0][0]; | ||
|
||
expect(stripesMock.hasPerm).toHaveBeenCalled(); | ||
expect(actionSuppressor.edit()).toBeFalsy(); | ||
expect(actionSuppressor.delete()).toBeFalsy(); | ||
}); | ||
}); |
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 @@ | ||
export { default as CategorySettings } from './CategorySettings'; |
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