From c56b6fe62e3bd98a79eb8967c6137c614dd70998 Mon Sep 17 00:00:00 2001 From: Sofiya Tepikin Date: Sun, 18 Sep 2022 15:21:55 +0200 Subject: [PATCH] Test --- components/settings/License.js | 27 +++++++++++++++++++++++++++ test/License.spec.js | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 components/settings/License.js create mode 100644 test/License.spec.js diff --git a/components/settings/License.js b/components/settings/License.js new file mode 100644 index 0000000..69b1fcd --- /dev/null +++ b/components/settings/License.js @@ -0,0 +1,27 @@ +import React from 'react' +import PropTypes from 'prop-types' +import { useTranslation } from 'react-i18next' + +import AppPage from '../common/app-page' +import AppText from '../common/app-text' +import Segment from '../common/segment' + +const License = ({ children }) => { + const { t } = useTranslation() + const currentYear = new Date().getFullYear() + + return ( + + + {t('settings.license.text', { currentYear })} + {children} + + + ) +} + +License.propTypes = { + children: PropTypes.node, +} + +export default License diff --git a/test/License.spec.js b/test/License.spec.js new file mode 100644 index 0000000..c68e7e9 --- /dev/null +++ b/test/License.spec.js @@ -0,0 +1,19 @@ +import React from 'react' +import { render, screen } from '@testing-library/react-native' +import License from '../components/settings/License' + +jest.mock('react-i18next', () => ({ + useTranslation: () => ({ + t: (str, options) => { + return str + (options ? JSON.stringify(options) : '') + }, + }), +})) + +describe('License screen', () => { + test('It should have a correct year', async () => { + render( {}} />) + const year = new Date().getFullYear().toString() + screen.getByText(year, { exact: false }) + }) +})