Front: i18n: Tests translation and action dispatch

This commit is contained in:
Arthi-chaud
2022-08-12 11:11:57 +02:00
parent b16ef2276c
commit 8766b308ee
5 changed files with 81 additions and 10 deletions
+15 -4
View File
@@ -1,13 +1,24 @@
import React from 'react';
import { Provider } from 'react-redux';
import TestRenderer from 'react-test-renderer';
import store from '../state/Store';
import { fireEvent, render, screen } from '@testing-library/react-native';
import HomeView from '../views/HomeView';
import { en, fr } from '../i18n/Translations';
describe('<HomeView />', () => {
it('has 2 children', () => {
const tree = TestRenderer.create(<Provider store={store}><HomeView /></Provider>).toJSON();
expect(tree.children.length).toBe(2);
const view = <Provider store={store}><HomeView /></Provider>;
beforeEach(() => render(view));
it('has should display the text in default language', async () => {
expect((await screen.findAllByText(en.signoutBtn)).length).toBe(1);
});
it('has should display the text in the new language', async () => {
fireEvent.press(screen.getByText('Change language'));
expect(store.getState().language.value).toBe('fr');
screen.update(view);
expect((await screen.findAllByText(fr.signoutBtn)).length).toBe(1);
});
});