fix: update tests for dk0 logo and boneyard-js mock, add jest moduleNameMapper
This commit is contained in:
@@ -2,16 +2,13 @@ import { render, screen, waitFor } from "@testing-library/react";
|
||||
import CurrentlyReadingComp from "@/app/components/CurrentlyReading";
|
||||
import React from "react";
|
||||
|
||||
// Mock next-intl completely to avoid ESM issues
|
||||
jest.mock("next-intl", () => ({
|
||||
useTranslations: () => (key: string) => key,
|
||||
useLocale: () => "en",
|
||||
}));
|
||||
|
||||
// Mock next/image
|
||||
jest.mock("next/image", () => ({
|
||||
__esModule: true,
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
default: (props: React.ImgHTMLAttributes<HTMLImageElement>) => <img {...props} alt={props.alt || ""} />,
|
||||
}));
|
||||
|
||||
@@ -22,8 +19,8 @@ describe("CurrentlyReading Component", () => {
|
||||
|
||||
it("renders skeleton when loading", () => {
|
||||
(global.fetch as jest.Mock).mockReturnValue(new Promise(() => {}));
|
||||
const { container } = render(<CurrentlyReadingComp />);
|
||||
expect(container.querySelector(".animate-pulse")).toBeInTheDocument();
|
||||
render(<CurrentlyReadingComp />);
|
||||
expect(screen.getByTestId("boneyard-skeleton")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders a book when data is fetched", async () => {
|
||||
|
||||
@@ -23,7 +23,7 @@ jest.mock('next/navigation', () => ({
|
||||
describe('Header', () => {
|
||||
it('renders the header with the dk logo', () => {
|
||||
render(<Header />);
|
||||
expect(screen.getByText('dk')).toBeInTheDocument();
|
||||
expect(screen.getByText('dk0')).toBeInTheDocument();
|
||||
|
||||
// Check for navigation links (appear in both desktop and mobile menus)
|
||||
expect(screen.getAllByText('Home').length).toBeGreaterThan(0);
|
||||
|
||||
Reference in New Issue
Block a user