Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 174 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"jest-environment-jsdom": "^30.4.1",
"tailwindcss": "^4",
"ts-jest": "^29.4.11",
"ts-node": "^10.9.2",
"typescript": "^5"
},
"overrides": {
Expand Down
8 changes: 4 additions & 4 deletions src/app/auth/callback/CallbackClient.test.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from "react";
import { render, screen, waitFor } from "@testing-library/react";
import { useSearchParams } from "next/navigation";
import { useRouter, useSearchParams } from "next/navigation";
import { CallbackClient } from "./CallbackClient";
import { useAuth } from "@/context/AuthContext";
import type { AuthUser } from "@/types";

jest.mock("next/navigation", () => ({
useSearchParams: jest.fn(),
useRouter: () => ({ replace: jest.fn() }),
useRouter: jest.fn(() => ({ replace: jest.fn() })),
}));

jest.mock("@/context/AuthContext", () => ({
Expand All @@ -20,6 +20,7 @@ const mockReplace = jest.fn();
const mockedUseAuth = useAuth as jest.MockedFunction<any>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mockedUseSearchParams = useSearchParams as jest.MockedFunction<any>;
const mockedUseRouter = useRouter as jest.Mock;

function makeUser(roles: string[]): AuthUser {
return {
Expand All @@ -35,8 +36,7 @@ function makeUser(roles: string[]): AuthUser {
describe("CallbackClient — role-based redirect (issue #77)", () => {
beforeEach(() => {
jest.clearAllMocks();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(require("next/navigation").useRouter = () => ({ replace: mockReplace }));
mockedUseRouter.mockReturnValue({ replace: mockReplace });
mockedUseSearchParams.mockReturnValue(new URLSearchParams({ token: "jwt-token" }));
});

Expand Down
8 changes: 6 additions & 2 deletions src/components/bounty/BountyCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ describe("BountyCard — description preview", () => {
});

describe("BountyCard — deadline countdown (#216)", () => {
it('shows "Xd left" for a future deadline', () => {
it('shows "X days left" for a future deadline', () => {
// formatDaysUntil (src/lib/utils.ts) is the actual, deliberate
// implementation this renders through — properly pluralized ("1 day
// left" vs "N days left"), not the abbreviated "Xd left" this test
// previously (and incorrectly) expected.
const deadline = new Date(Date.now() + 5 * 24 * 60 * 60 * 1000).toISOString();
render(<BountyCard bounty={makeBounty({ deadline })} />);
expect(screen.getByText("5d left")).toBeInTheDocument();
expect(screen.getByText("5 days left")).toBeInTheDocument();
});

it('shows "Deadline passed" for a past deadline', () => {
Expand Down
Loading
Loading