From a8ba435d413f6566a65e5af0e9e1ba8f68312e85 Mon Sep 17 00:00:00 2001 From: AlvaroGlezC Date: Sat, 27 Apr 2024 14:45:54 +0200 Subject: [PATCH] =?UTF-8?q?#29=20Se=20a=C3=B1aden=20tests=20unitarios=20a?= =?UTF-8?q?=20los=20componentes=20y=20pantallas,=20tambien=20se=20a=C3=B1a?= =?UTF-8?q?de=20el=20covarage=20de=20estos=20componentes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- syg-frontend/package.json | 16 +++- syg-frontend/src/App.test.tsx | 9 -- syg-frontend/src/App.tsx | 2 +- .../src/components/aside/Aside.test.tsx | 89 +++++++++++++++++++ syg-frontend/src/components/aside/Aside.tsx | 20 ++--- .../src/components/card/UserInfoCard.test.tsx | 46 ++++++++++ .../src/components/card/UserInfoCard.tsx | 11 +-- .../src/components/header/Header.test.tsx | 71 +++++++++++++++ syg-frontend/src/components/header/Header.tsx | 15 ++-- .../components/timers/QuestionTimer.test.tsx | 59 ++++++++++++ .../src/components/timers/QuestionTimer.tsx | 6 +- syg-frontend/src/modules/content/Content.tsx | 4 +- .../src/modules/historic/Historic.tsx | 12 +-- .../src/modules/historic/Historics.test.tsx | 64 +++++++++++++ .../src/modules/ranking/Ranking.test.tsx | 39 ++++++++ syg-frontend/src/modules/ranking/Ranking.tsx | 4 +- syg-frontend/src/setupTests.ts | 6 +- syg-frontend/src/translation/i18n.js | 2 +- 18 files changed, 421 insertions(+), 54 deletions(-) delete mode 100644 syg-frontend/src/App.test.tsx create mode 100644 syg-frontend/src/components/aside/Aside.test.tsx create mode 100644 syg-frontend/src/components/card/UserInfoCard.test.tsx create mode 100644 syg-frontend/src/components/header/Header.test.tsx create mode 100644 syg-frontend/src/components/timers/QuestionTimer.test.tsx create mode 100644 syg-frontend/src/modules/historic/Historics.test.tsx create mode 100644 syg-frontend/src/modules/ranking/Ranking.test.tsx diff --git a/syg-frontend/package.json b/syg-frontend/package.json index 507c5a3..eee7a72 100644 --- a/syg-frontend/package.json +++ b/syg-frontend/package.json @@ -33,7 +33,8 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "coverage": "npm test -- --coverage --watchAll" }, "eslintConfig": { "extends": [ @@ -52,5 +53,16 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "jest": { + "coveragePathIgnorePatterns": [ + "/node_modules/", + "/src/App.tsx", + "/src/modules/content/Content.tsx", + "/src/index.tsx", + "/src/reportWebVitals.ts", + "/src/secure/", + "/src/backend/dataSource.ts" + ] } -} +} \ No newline at end of file diff --git a/syg-frontend/src/App.test.tsx b/syg-frontend/src/App.test.tsx deleted file mode 100644 index 2a68616..0000000 --- a/syg-frontend/src/App.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import { render, screen } from '@testing-library/react'; -import App from './App'; - -test('renders learn react link', () => { - render(); - const linkElement = screen.getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/syg-frontend/src/App.tsx b/syg-frontend/src/App.tsx index 6ac53ae..74c44e6 100644 --- a/syg-frontend/src/App.tsx +++ b/syg-frontend/src/App.tsx @@ -4,7 +4,7 @@ import './App.scss'; function App() { return ( - + ); } diff --git a/syg-frontend/src/components/aside/Aside.test.tsx b/syg-frontend/src/components/aside/Aside.test.tsx new file mode 100644 index 0000000..04e6a29 --- /dev/null +++ b/syg-frontend/src/components/aside/Aside.test.tsx @@ -0,0 +1,89 @@ +import { screen, render, fireEvent, act } from "@testing-library/react" +import Aside from "./Aside" +import i18n from '../../translation/i18n'; +import { MemoryRouter } from "react-router-dom"; + +describe('Header', () => { + beforeAll(() => { + i18n.changeLanguage('Spain'); + }); + + test('Aside renders correctly', () => { + render(