From 1c0448f34a8d7726016b7ee7e2069c889513a7b4 Mon Sep 17 00:00:00 2001 From: m-tartari <37861893+m-tartari@users.noreply.github.com> Date: Sat, 17 Feb 2024 16:06:36 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test(cv):=20add=20`CurriculumPage`?= =?UTF-8?q?=20unit=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CurriculumPage/CurriculumPage.test.tsx | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/components/pages/CurriculumPage/CurriculumPage.test.tsx diff --git a/src/components/pages/CurriculumPage/CurriculumPage.test.tsx b/src/components/pages/CurriculumPage/CurriculumPage.test.tsx new file mode 100644 index 0000000..874b190 --- /dev/null +++ b/src/components/pages/CurriculumPage/CurriculumPage.test.tsx @@ -0,0 +1,90 @@ +import { screen } from '@testing-library/react' +import userEvent from '@testing-library/user-event' + +import { renderWithRouter as render } from 'components/utils/tests' + +import CurriculumPage from '.' + +vi.stubGlobal('open', vi.fn()) + +describe('Curriculum component', () => { + const open = vi.spyOn(window, 'open') + + test('renders without crashing', () => { + render() + + expect(screen.getAllByText('Curriculum')).toHaveLength(3) // title, appbar button and appbar drawer button + }) + + test('displays the correct work experience', () => { + render() + + expect(screen.getByText('Work Experience')).toBeInTheDocument() + + // check some of the positions + expect(screen.getAllByText('Software Engineer')).toHaveLength(2) // large and smallscreen versions + expect(screen.getAllByText('Embedded Engineer')).toHaveLength(2) // large and smallscreen versions + }) + + test('displays the correct education', async () => { + render() + + // Education + expect(screen.getByText('Education')).toBeInTheDocument() + + // check the subsections links + await userEvent.click(screen.getByText('EMARO+ Program - Master Studies')) + expect(open).toHaveBeenCalledWith('https://master-emaro.ec-nantes.fr/', '_blank') + await userEvent.click(screen.getByText('Almatong Project - Bachelor Studies')) + expect(open).toHaveBeenCalledWith('https://corsi.unibo.it/2cycle/AutomationEngineering/almatong-bachelor-programme', '_blank') + + // check some of the entries + expect(screen.getAllByText('M.Eng. in Robotics and Control')).toHaveLength(2) // large and smallscreen versions + expect(screen.getAllByText('M.S. in Robotics and Control Engineering')).toHaveLength(2) // large and smallscreen versions + expect(screen.getAllByText('B.S. in Control Theory and Control Engineering')).toHaveLength(2) // large and smallscreen versions + }) + + test('displays the correct skills', () => { + render() + + expect(screen.getByText('Skills')).toBeInTheDocument() + + // check the subsection titles + expect(screen.getByText('Languages')).toBeInTheDocument() + expect(screen.getByText('Digital')).toBeInTheDocument() + expect(screen.getByText('Softskills')).toBeInTheDocument() + }) + + test('displays the correct accomplishments', async () => { + render() + + expect(screen.getByText('Accomplishments')).toBeInTheDocument() + + // check some of the awards + expect(screen.getByText('Awards')).toBeInTheDocument() + expect(screen.getByText('Premio Innovazione Robotica ed Automazione - Horizon')).toBeInTheDocument() + + // check some of the press releases + expect(screen.getByText('Press Releases')).toBeInTheDocument() + await userEvent.click(screen.getByText("Covid-19: L'impatto sui giovani talenti")) + expect(open).toHaveBeenCalledWith('https://www.youtube.com/watch?v=Blat-e2Vyzk&feature=youtu.be', '_blank') + + // check some of the certifications + expect(screen.getByText('Publications')).toBeInTheDocument() + expect(screen.getByText('Control System Design for Human Assisting Robot')).toBeInTheDocument() + }) + + test('displays the correct extracurricular activites', () => { + render() + + expect(screen.getByText('Extracurricular')).toBeInTheDocument() + + // check some of the activities + expect(screen.getByText('Volunteering')).toBeInTheDocument() + expect(screen.getByText('Blood Donor, Bone Marrow Donor at AVIS & ADMO')).toBeInTheDocument() + + // check some of the hobbies + expect(screen.getByText('Interests')).toBeInTheDocument() + expect(screen.getByText('Ju-jitsu')).toBeInTheDocument() + }) +})