From 2b0daaadbe35af2f4e3f6428800a6ca127d8a55b Mon Sep 17 00:00:00 2001 From: Martin Bohal Date: Fri, 20 Dec 2024 17:04:31 +0100 Subject: [PATCH] fixup! Split `RUIProvider` into two --- .../translations/TranslationsProvider.jsx | 4 +- .../__tests__/TranslationsProvider.test.jsx | 48 +++++++++++++------ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/providers/translations/TranslationsProvider.jsx b/src/providers/translations/TranslationsProvider.jsx index c776c197..e203e744 100644 --- a/src/providers/translations/TranslationsProvider.jsx +++ b/src/providers/translations/TranslationsProvider.jsx @@ -10,11 +10,11 @@ const TranslationsProvider = ({ children, translations, }) => { - const context = useContext(TranslationsContext); + const contextTranslations = useContext(TranslationsContext); return ( {children} diff --git a/src/providers/translations/__tests__/TranslationsProvider.test.jsx b/src/providers/translations/__tests__/TranslationsProvider.test.jsx index a5c957b2..a5c186e3 100644 --- a/src/providers/translations/__tests__/TranslationsProvider.test.jsx +++ b/src/providers/translations/__tests__/TranslationsProvider.test.jsx @@ -4,27 +4,47 @@ import { within, } from '@testing-library/react'; import { Alert } from '../../../components/Alert'; +import { ScrollView } from '../../../components/ScrollView'; import TranslationsProvider from '../TranslationsProvider'; describe('rendering', () => { - it.each([ - [ - { - children: {}}>alert text, - translations: { + it('renders with translations', () => { + const dom = render(( + expect(within(rootElement).getByTitle('Zavřít')), - ], - ])('renders with props: "%s"', (testedProps, assert) => { + }} + > + {}}>alert text + + + )); + + expect(within(dom.container.firstChild).getByTitle('Zavřít')); + }); + + it('renders with nested translations', () => { const dom = render(( + translations={{ + ScrollView: { + next: 'Další', + previous: 'Předchozí', + }, + }} + > + + some scrolable text + + + )); - assert(dom.container.firstChild); + expect(within(dom.container.firstChild).getByTitle('Předchozí')); + expect(within(dom.container.firstChild).getByTitle('Sigiente')); }); }); -