-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,243 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/// <reference types="@testing-library/jest-dom" /> | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { describe, expect, test } from "vitest"; | ||
import SectionAwards from "../src/SectionAwards"; | ||
import { LocaleContext } from "../src/I18NResume"; | ||
import type { Award } from "../src/interfaces"; | ||
import strings from "../src/strings.json"; | ||
|
||
const mockLocaleContext = { | ||
locale: "en", | ||
strings, | ||
}; | ||
|
||
describe("SectionAwards Component", () => { | ||
test("renders nothing when awards array is empty", () => { | ||
const { container } = render( | ||
<LocaleContext.Provider value={mockLocaleContext}> | ||
<SectionAwards awards={[]} /> | ||
</LocaleContext.Provider> | ||
); | ||
|
||
expect(container.firstChild).toBeNull(); | ||
}); | ||
|
||
test("renders awards when provided", () => { | ||
const awards: Award[] = [ | ||
{ | ||
key: "award1", | ||
title: "Best Developer", | ||
awarder: "Tech Conference", | ||
date: "2023-05-15", | ||
summary: "Awarded for outstanding contributions to open source", | ||
}, | ||
{ | ||
key: "award2", | ||
title: "Innovation Prize", | ||
awarder: "Startup Incubator", | ||
summary: "Recognized for creating a groundbreaking app", | ||
}, | ||
]; | ||
|
||
render( | ||
<LocaleContext.Provider value={mockLocaleContext}> | ||
<SectionAwards awards={awards} /> | ||
</LocaleContext.Provider> | ||
); | ||
|
||
expect(screen.getByText("Awards")).toBeInTheDocument(); | ||
expect(screen.getByText("Best Developer")).toBeInTheDocument(); | ||
expect(screen.getByText("Innovation Prize")).toBeInTheDocument(); | ||
}); | ||
|
||
test("handles awards without dates", () => { | ||
const awards: Award[] = [ | ||
{ | ||
key: "award1", | ||
title: "Innovation Prize", | ||
awarder: "Startup Incubator", | ||
summary: "Recognized for creating a groundbreaking app", | ||
}, | ||
]; | ||
|
||
render( | ||
<LocaleContext.Provider value={mockLocaleContext}> | ||
<SectionAwards awards={awards} /> | ||
</LocaleContext.Provider> | ||
); | ||
|
||
expect(screen.queryByText(/\d{4}-\d{2}-\d{2}/)).not.toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/// <reference types="@testing-library/jest-dom" /> | ||
import { render, screen } from "@testing-library/react"; | ||
import { describe, expect, test } from "vitest"; | ||
import SectionCertificates from "../src/SectionCertificates"; | ||
import { LocaleContext } from "../src/I18NResume"; | ||
import React from "react"; | ||
import strings from "../src/strings.json"; | ||
|
||
const mockLocaleContext = { | ||
locale: "en", | ||
strings, | ||
}; | ||
|
||
describe("SectionCertificates Component", () => { | ||
const renderWithLocale = (ui, { localeValue = mockLocaleContext } = {}) => { | ||
return render( | ||
<LocaleContext.Provider value={localeValue}>{ui}</LocaleContext.Provider> | ||
); | ||
}; | ||
|
||
test("renders nothing when no certificates are provided", () => { | ||
renderWithLocale(<SectionCertificates certificates={undefined} />); | ||
expect(screen.queryByRole("list")).not.toBeInTheDocument(); | ||
}); | ||
|
||
test("renders certificate list when certificates are provided", () => { | ||
const certificates = [ | ||
{ | ||
key: "1", | ||
name: "Certificate 1", | ||
issuer: "Issuer 1", | ||
date: "2023-06-01", | ||
url: "https://example.com", | ||
keywords: ["cert1"], | ||
}, | ||
]; | ||
renderWithLocale(<SectionCertificates certificates={certificates} />, { | ||
localeValue: mockLocaleContext, | ||
}); | ||
|
||
expect( | ||
screen.getByRole("heading", { name: "Certificates Collapse section" }) | ||
).toBeInTheDocument(); | ||
expect(screen.getByText("Certificate 1")).toBeInTheDocument(); | ||
expect(screen.getByText(". Issuer 1")).toBeInTheDocument(); | ||
expect(screen.getByRole("link")).toHaveAttribute( | ||
"href", | ||
"https://example.com" | ||
); | ||
}); | ||
|
||
test("renders certificate without link when url is not provided", () => { | ||
const certificates = [ | ||
{ | ||
key: "2", | ||
name: "Certificate 2", | ||
issuer: "Issuer 2", | ||
date: "2023-07-01", | ||
url: "", | ||
keywords: ["cert2"], | ||
}, | ||
]; | ||
renderWithLocale(<SectionCertificates certificates={certificates} />, { | ||
localeValue: mockLocaleContext, | ||
}); | ||
|
||
expect( | ||
screen.getByRole("heading", { name: "Certificates Collapse section" }) | ||
).toBeInTheDocument(); | ||
expect(screen.getByText("Certificate 2")).toBeInTheDocument(); | ||
expect(screen.getByText(". Issuer 2")).toBeInTheDocument(); | ||
expect(screen.queryByRole("link")).not.toBeInTheDocument(); | ||
}); | ||
|
||
test("applies OpacityFilter to certificates", () => { | ||
const certificates = [ | ||
{ | ||
key: "3", | ||
name: "Certificate 3", | ||
issuer: "Issuer 3", | ||
date: "2023-08-01", | ||
url: "", | ||
keywords: ["cert3"], | ||
}, | ||
]; | ||
renderWithLocale(<SectionCertificates certificates={certificates} />, { | ||
localeValue: mockLocaleContext, | ||
}); | ||
|
||
const filterElement = screen.getByText("Certificate 3").closest("div"); | ||
expect(filterElement).toHaveClass("transition-opacity"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/// <reference types="@testing-library/jest-dom" /> | ||
import { render, screen } from "@testing-library/react"; | ||
import { describe, expect, test } from "vitest"; | ||
import SectionContact from "../src/SectionContact"; | ||
import { LocaleContext } from "../src/I18NResume"; | ||
import React from "react"; | ||
import strings from "../src/strings.json"; | ||
|
||
const mockLocaleContext = { | ||
locale: "en", | ||
strings, | ||
}; | ||
|
||
describe("SectionContact Component", () => { | ||
const renderWithLocale = (ui, { localeValue = mockLocaleContext } = {}) => { | ||
return render( | ||
<LocaleContext.Provider value={localeValue}>{ui}</LocaleContext.Provider> | ||
); | ||
}; | ||
|
||
test("renders nothing when no contact information is provided", () => { | ||
renderWithLocale(<SectionContact basics={undefined} />); | ||
expect(screen.queryByRole("list")).not.toBeInTheDocument(); | ||
}); | ||
|
||
test("renders contact section with email", () => { | ||
const basics = { | ||
email: "test@example.com", | ||
}; | ||
renderWithLocale(<SectionContact basics={basics} />, { | ||
localeValue: mockLocaleContext, | ||
}); | ||
|
||
expect( | ||
screen.getByRole("heading", { | ||
name: "Contact information Collapse section", | ||
}) | ||
).toBeInTheDocument(); | ||
expect(screen.getByText("test@example.com")).toBeInTheDocument(); | ||
expect(screen.getByLabelText("Email")).toBeInTheDocument(); | ||
}); | ||
|
||
test("renders contact section with phone", () => { | ||
const basics = { | ||
phone: "123-456-7890", | ||
}; | ||
renderWithLocale(<SectionContact basics={basics} />, { | ||
localeValue: mockLocaleContext, | ||
}); | ||
|
||
expect( | ||
screen.getByRole("heading", { | ||
name: "Contact information Collapse section", | ||
}) | ||
).toBeInTheDocument(); | ||
expect(screen.getByText("123-456-7890")).toBeInTheDocument(); | ||
expect(screen.getByLabelText("Phone")).toBeInTheDocument(); | ||
}); | ||
|
||
test("renders contact section with address", () => { | ||
const basics = { | ||
location: { city: "City", countryCode: "US" }, | ||
}; | ||
renderWithLocale(<SectionContact basics={basics} />, { | ||
localeValue: mockLocaleContext, | ||
}); | ||
|
||
expect( | ||
screen.getByRole("heading", { | ||
name: "Contact information Collapse section", | ||
}) | ||
).toBeInTheDocument(); | ||
expect(screen.getByLabelText("Address")).toBeInTheDocument(); | ||
}); | ||
|
||
test("renders contact section with all details", () => { | ||
const basics = { | ||
email: "test@example.com", | ||
phone: "123-456-7890", | ||
location: { city: "City", countryCode: "US" }, | ||
}; | ||
renderWithLocale(<SectionContact basics={basics} />, { | ||
localeValue: mockLocaleContext, | ||
}); | ||
|
||
expect( | ||
screen.getByRole("heading", { | ||
name: "Contact information Collapse section", | ||
}) | ||
).toBeInTheDocument(); | ||
expect(screen.getByText("test@example.com")).toBeInTheDocument(); | ||
expect(screen.getByText("123-456-7890")).toBeInTheDocument(); | ||
expect(screen.getByLabelText("Email")).toBeInTheDocument(); | ||
expect(screen.getByLabelText("Phone")).toBeInTheDocument(); | ||
expect(screen.getByLabelText("Address")).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.