diff --git a/src/head/Head.jsx b/src/head/Head.jsx index b84fd32..2478153 100644 --- a/src/head/Head.jsx +++ b/src/head/Head.jsx @@ -1,21 +1,26 @@ import React from 'react'; import { Helmet } from 'react-helmet'; -import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { useIntl } from '@edx/frontend-platform/i18n'; import { getConfig } from '@edx/frontend-platform'; import messages from './messages'; -const Head = ({ intl }) => ( - - - {intl.formatMessage(messages['profile.page.title'], { siteName: getConfig().SITE_NAME })} - - - -); - -Head.propTypes = { - intl: intlShape.isRequired, +const Head = () => { + const intl = useIntl(); + return ( + + + {intl.formatMessage(messages['profile.page.title'], { + siteName: getConfig().SITE_NAME, + })} + + + + ); }; -export default injectIntl(Head); +export default Head; diff --git a/src/profile/forms/elements/EditButton.jsx b/src/profile/forms/elements/EditButton.jsx index 80cb479..61c1373 100644 --- a/src/profile/forms/elements/EditButton.jsx +++ b/src/profile/forms/elements/EditButton.jsx @@ -1,46 +1,41 @@ import React from 'react'; import PropTypes from 'prop-types'; import { EditOutline } from '@openedx/paragon/icons'; -import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { useIntl } from '@edx/frontend-platform/i18n'; import { Button, OverlayTrigger, Tooltip } from '@openedx/paragon'; import messages from './EditButton.messages'; -const EditButton = ({ - onClick, className, style, intl, -}) => ( - -

- {intl.formatMessage(messages['profile.editbutton.edit'])} -

- - )} - > - -
-); + + + ); +}; -export default injectIntl(EditButton); +export default EditButton; EditButton.propTypes = { onClick: PropTypes.func.isRequired, className: PropTypes.string, style: PropTypes.object, // eslint-disable-line - intl: intlShape.isRequired, -}; - -EditButton.defaultProps = { - className: null, - style: null, }; diff --git a/src/profile/forms/elements/EditButton.test.jsx b/src/profile/forms/elements/EditButton.test.jsx new file mode 100644 index 0000000..2d9d8c4 --- /dev/null +++ b/src/profile/forms/elements/EditButton.test.jsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { render, fireEvent } from '@testing-library/react'; +import { IntlProvider } from '@edx/frontend-platform/i18n'; +import EditButton from './EditButton'; + +const messages = { + 'profile.editbutton.edit': 'Edit', +}; + +describe('EditButton', () => { + it('renders and calls onClick when clicked', () => { + const onClick = jest.fn(); + const { getByRole } = render( + + + , + ); + const button = getByRole('button'); + fireEvent.click(button); + expect(onClick).toHaveBeenCalled(); + }); +}); diff --git a/src/profile/forms/elements/EditableItemHeader.jsx b/src/profile/forms/elements/EditableItemHeader.jsx index 5381e3a..6b82abc 100644 --- a/src/profile/forms/elements/EditableItemHeader.jsx +++ b/src/profile/forms/elements/EditableItemHeader.jsx @@ -7,12 +7,12 @@ import { Visibility } from './Visibility'; import { useIsOnMobileScreen } from '../../data/hooks'; const EditableItemHeader = ({ - content, - showVisibility, - visibility, - showEditButton, - onClickEdit, - headingId, + content = '', + showVisibility = false, + visibility = 'private', + showEditButton = false, + onClickEdit = () => {}, + headingId = null, }) => { const isMobileView = useIsOnMobileScreen(); return ( @@ -57,13 +57,3 @@ EditableItemHeader.propTypes = { visibility: PropTypes.oneOf(['private', 'all_users']), headingId: PropTypes.string, }; - -EditableItemHeader.defaultProps = { - onClickEdit: () => { - }, - showVisibility: false, - showEditButton: false, - content: '', - visibility: 'private', - headingId: null, -}; diff --git a/src/profile/forms/elements/EmptyContent.jsx b/src/profile/forms/elements/EmptyContent.jsx index 3978d80..4d6b83d 100644 --- a/src/profile/forms/elements/EmptyContent.jsx +++ b/src/profile/forms/elements/EmptyContent.jsx @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faPlus } from '@fortawesome/free-solid-svg-icons'; -const EmptyContent = ({ children, onClick, showPlusIcon }) => ( +const EmptyContent = ({ children = null, onClick = null, showPlusIcon = true }) => (
{onClick ? (