|
2 | 2 | * @jest-environment jsdom
|
3 | 3 | */
|
4 | 4 |
|
| 5 | +import React from "react"; |
5 | 6 | import { render, screen } from "@testing-library/react";
|
6 |
| - |
7 | 7 | import CVContent from "../../src/components/CV/CVContent.component";
|
8 | 8 |
|
| 9 | +const mockCVData = { |
| 10 | + keyQualifications: ["Qualification 1", "Qualification 2"], |
| 11 | + experience: [ |
| 12 | + { |
| 13 | + period: "2020-2022", |
| 14 | + company: "Example Company", |
| 15 | + role: "Software Developer", |
| 16 | + description: "Worked on various projects", |
| 17 | + }, |
| 18 | + ], |
| 19 | + education: [ |
| 20 | + { |
| 21 | + period: "2016-2020", |
| 22 | + institution: "University of Example", |
| 23 | + degree: "Bachelor in Computer Science", |
| 24 | + description: "Studied various aspects of computer science", |
| 25 | + }, |
| 26 | + ], |
| 27 | +}; |
| 28 | + |
9 | 29 | describe("CVContent", () => {
|
10 |
| - it("CVContent laster inn og kan vises", () => { |
11 |
| - render(<CVContent />); |
12 |
| - const cvcontent = screen.getByRole("heading", { name: /cv/i }); |
13 |
| - expect(cvcontent).toBeInTheDocument(); |
14 |
| - }); |
| 30 | + it("CVContent renders correctly with mock data", () => { |
| 31 | + render(<CVContent cvData={mockCVData} />); |
| 32 | + |
| 33 | + // Check if the CV header is present |
| 34 | + const cvHeader = screen.getByRole("heading", { name: /cv/i }); |
| 35 | + expect(cvHeader).toBeInTheDocument(); |
| 36 | + |
| 37 | + // Check if the "Last ned PDF" button is present |
| 38 | + const pdfButton = screen.getByRole("link", { name: /last ned pdf/i }); |
| 39 | + expect(pdfButton).toBeInTheDocument(); |
| 40 | + |
| 41 | + // Check if tabs are present |
| 42 | + const qualificationsTab = screen.getByRole("tab", { |
| 43 | + name: /nøkkelkvalifikasjoner/i, |
| 44 | + }); |
| 45 | + const experienceTab = screen.getByRole("tab", { name: /erfaring/i }); |
| 46 | + const educationTab = screen.getByRole("tab", { name: /utdanning/i }); |
| 47 | + expect(qualificationsTab).toBeInTheDocument(); |
| 48 | + expect(experienceTab).toBeInTheDocument(); |
| 49 | + expect(educationTab).toBeInTheDocument(); |
15 | 50 |
|
16 |
| - /* |
17 |
| - it("PDF laster inn og kan vises", async () => { |
18 |
| - render(<CVContent />); |
19 |
| - const pdf = await screen.findByText(/nøkkelkvalifikasjoner/i); |
20 |
| - expect(pdf).toBeInTheDocument(); |
| 51 | + // Check if mock data is rendered (you might need to click on tabs to see this content) |
| 52 | + const qualification = screen.getByText(/qualification 1/i); |
| 53 | + expect(qualification).toBeInTheDocument(); |
21 | 54 | });
|
22 |
| - */ |
23 | 55 | });
|
0 commit comments