Front: i18n: Tests translation and action dispatch
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user