Skip to content

Commit

Permalink
UIU-3005 - add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Terala-Priyanka committed Feb 5, 2024
1 parent 2cb0847 commit 7c22357
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/components/EditSections/EditUserInfo/EditUserInfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import EditUserInfo from './EditUserInfo';
import { isConsortiumEnabled } from '../../util';
import { USER_TYPES } from '../../../constants';

jest.mock('../../../hooks', () => ({
useProfilePicture: jest.fn(),
}));
jest.mock('@folio/stripes/components', () => ({
...jest.requireActual('@folio/stripes/components'),
Modal: jest.fn(({ children, label, footer, ...rest }) => {
Expand All @@ -34,6 +37,8 @@ jest.mock('../../util', () => ({
isConsortiumEnabled: jest.fn(() => true),
}));

jest.mock('./components/ProfilePicture', () => jest.fn(() => 'Profile Picture'));

const onSubmit = jest.fn();

const arrayMutators = {
Expand Down Expand Up @@ -122,7 +127,8 @@ const props = {
PUT: jest.fn(),
cancel: jest.fn(),
reset: jest.fn()
}
},
areProfilePicturesEnabled: true,
};

describe('Render Edit User Information component', () => {
Expand Down Expand Up @@ -183,4 +189,16 @@ describe('Render Edit User Information component', () => {
expect(screen.getByRole('textbox', { name: /lastName/ })).toBeDisabled();
expect(screen.getByRole('textbox', { name: /firstName/ })).toBeDisabled();
});

it('should display profile picture', () => {
renderEditUserInfo(props);
expect(screen.getByText('Profile Picture')).toBeInTheDocument();
});

describe('when profilePicture configuration is not enabled', () => {
it('should not render profile picture', () => {
renderEditUserInfo({ ...props, areProfilePicturesEnabled: false });
expect(screen.queryByText('Profile Picture')).not.toBeInTheDocument();
});
});
});
1 change: 1 addition & 0 deletions src/views/UserDetail/UserDetail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ describe('UserDetail', () => {

beforeEach(() => {
stripes = useStripes();
stripes.hasPerm = () => true;
mutator.hasManualPatronBlocks.GET.mockImplementation(() => Promise.resolve([]));
mutator.hasAutomatedPatronBlocks.GET.mockImplementation(() => Promise.resolve([]));
});
Expand Down

0 comments on commit 7c22357

Please sign in to comment.