Updating PrivacyPolicy to use hooks

This commit is contained in:
Jeff Avallone 2019-03-26 20:42:16 -04:00
parent c6020a225f
commit f9b3d5dbd7
4 changed files with 17 additions and 21 deletions

View File

@ -9,7 +9,7 @@ exports[`Header opening the Privacy Policy modal 1`] = `
}"
>
<span
data-component="withI18nextTranslation(PrivacyPolicy)"
data-component="PrivacyPolicy"
data-props="{}"
/>
</span>
@ -85,7 +85,7 @@ exports[`Header opening the Privacy Policy modal while holding alt key 1`] = `
}"
>
<span
data-component="withI18nextTranslation(PrivacyPolicy)"
data-component="PrivacyPolicy"
data-props="{}"
/>
</span>
@ -161,7 +161,7 @@ exports[`Header opening the Privacy Policy modal while holding ctrl key 1`] = `
}"
>
<span
data-component="withI18nextTranslation(PrivacyPolicy)"
data-component="PrivacyPolicy"
data-props="{}"
/>
</span>
@ -237,7 +237,7 @@ exports[`Header opening the Privacy Policy modal while holding meta key 1`] = `
}"
>
<span
data-component="withI18nextTranslation(PrivacyPolicy)"
data-component="PrivacyPolicy"
data-props="{}"
/>
</span>
@ -313,7 +313,7 @@ exports[`Header opening the Privacy Policy modal while holding shift key 1`] = `
}"
>
<span
data-component="withI18nextTranslation(PrivacyPolicy)"
data-component="PrivacyPolicy"
data-props="{}"
/>
</span>
@ -389,7 +389,7 @@ exports[`Header rendering 1`] = `
}"
>
<span
data-component="withI18nextTranslation(PrivacyPolicy)"
data-component="PrivacyPolicy"
data-props="{}"
/>
</span>
@ -466,7 +466,7 @@ exports[`Header rendering with no banner 1`] = `
}"
>
<span
data-component="withI18nextTranslation(PrivacyPolicy)"
data-component="PrivacyPolicy"
data-props="{}"
/>
</span>

View File

@ -1,11 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withTranslation, Trans } from 'react-i18next';
import { useTranslation, Trans } from 'react-i18next';
import Message from 'components/Message';
export const PrivacyPolicy = ({ t, ...props }) => (
<Message type="info" heading={ t('Privacy Policy') } { ...props }>
export const PrivacyPolicy = props => {
const { t } = useTranslation();
return <Message type="info" heading={ t('Privacy Policy') } { ...props }>
<Trans i18nKey="Privacy policy copy">
<p>
Regexper and the tools used to create it are all open source. If you are
@ -44,11 +45,7 @@ export const PrivacyPolicy = ({ t, ...props }) => (
Regexper is not supported by ad revenue or sales of any kind.
</p>
</Trans>
</Message>
);
PrivacyPolicy.propTypes = {
t: PropTypes.func.isRequired
</Message>;
};
export default withTranslation()(PrivacyPolicy);
export default PrivacyPolicy;

View File

@ -4,13 +4,12 @@ jest.mock('components/Message', () =>
import React from 'react';
import { render } from 'react-testing-library';
import { mockT } from 'i18n';
import { PrivacyPolicy } from 'components/PrivacyPolicy';
import PrivacyPolicy from 'components/PrivacyPolicy';
describe('PrivacyPolicy', () => {
test('rendering', () => {
const { asFragment } = render(
<PrivacyPolicy onClose={ jest.fn() } t={ mockT } />
<PrivacyPolicy onClose={ jest.fn() } />
);
expect(asFragment()).toMatchSnapshot();
});

View File

@ -9,7 +9,7 @@ exports[`Privacy Page rendering 1`] = `
}"
/>
<span
data-component="withI18nextTranslation(PrivacyPolicy)"
data-component="PrivacyPolicy"
data-props="{}"
/>
</DocumentFragment>