From 9a82858662f85069407c96a66004b6a668f3e80b Mon Sep 17 00:00:00 2001 From: danis Date: Mon, 21 Nov 2022 11:42:39 +0300 Subject: [PATCH] so far so good --- front/views/AuthenticationView.test.tsx | 20 ++++++++++++++++---- front/views/HomeView.test.tsx | 5 ++--- front/views/SettingsView.test.tsx | 14 ++++++++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/front/views/AuthenticationView.test.tsx b/front/views/AuthenticationView.test.tsx index a2152ab..3006d1c 100644 --- a/front/views/AuthenticationView.test.tsx +++ b/front/views/AuthenticationView.test.tsx @@ -8,16 +8,28 @@ import { useLanguage } from '../state/LanguageSlice'; import renderer from 'react-test-renderer' import { NativeBaseProvider } from "native-base"; import Theme from '../Theme'; +import { setUserToken } from '../state/UserSlice'; describe('AuthenticationView Component', () => { jest.setTimeout(150000); const view = () => ; + beforeEach(() => render(view())); - it('should render correctly', () => { - let truc = render(view()).toJSON(); - expect(truc).toBeDefined(); - }) + + it('view should render', () => { + expect(screen).toBeDefined(); + }); + + // it('should render forms', async () => { + // expect(await screen.findByDisplayValue('username')).toBeTruthy(); + // }); + it('renders the submit button', () => { + expect(screen.findAllByText('en.signinBtn')).toBeTruthy(); + }); + // it('renders the forms', async () => { + // expect(screen.findAllByPlaceholderText) + // }) // const view = () => ; // beforeEach(() => render(view())); diff --git a/front/views/HomeView.test.tsx b/front/views/HomeView.test.tsx index 01d89df..5e53078 100644 --- a/front/views/HomeView.test.tsx +++ b/front/views/HomeView.test.tsx @@ -12,13 +12,12 @@ describe('', () => { jest.setTimeout(150000); const view = () => ; + beforeEach(() => render(view())); it('should render correctly', () => { - let truc = render(view()).toJSON(); - expect(truc).toBeDefined(); + expect(screen).toBeDefined(); }) - // beforeEach(() => render(view)); // it('has should display the text in default language', async () => { // expect((await screen.findAllByText(en.signoutBtn)).length).toBe(1); diff --git a/front/views/SettingsView.test.tsx b/front/views/SettingsView.test.tsx index 8b28701..aa9402c 100644 --- a/front/views/SettingsView.test.tsx +++ b/front/views/SettingsView.test.tsx @@ -3,7 +3,7 @@ import { Provider } from 'react-redux'; import TestRenderer from 'react-test-renderer'; import store from '../state/Store'; -import { NativeBaseProvider } from "native-base"; +import { Button, NativeBaseProvider } from "native-base"; import Theme from '../Theme'; import { fireEvent, render, screen } from '@testing-library/react-native'; @@ -15,8 +15,14 @@ describe('testing Setting\'s main view', () => { const MainView = () => ; const PreferencesView = () => ; - it('should render correctly', () => { - let truc = render(MainView()).toJSON(); - expect(truc).toBeDefined(); + render(MainView()); + it('Main View should render correctly', async () => { + + expect(screen.findAllByText('en.prefBtn')).toBeTruthy(); }) + + // it('Preference View should render correctly', async() => { + // render(PreferencesView()); + // expect(screen.findAllByText('en.backBtn')).toBeTruthy(); + // }) }); \ No newline at end of file