Skip to content

Commit da30bf2

Browse files
committed
move test files
1 parent 37a529a commit da30bf2

19 files changed

+133
-186
lines changed

src/components/__tests__/GenreBadge.test.tsx renamed to src/components/GenreBadge.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it, vi, beforeEach } from "vitest";
22
import { render, screen } from "@testing-library/react";
3-
import { GenreBadge } from "../GenreBadge";
3+
import { GenreBadge } from "./GenreBadge";
44
import * as useGenresModule from "@/hooks/queries/genres/useGenres";
55

66
vi.mock("@/hooks/queries/genres/useGenres");

src/components/__tests__/StageBadge.test.tsx renamed to src/components/StageBadge.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from "vitest";
22
import { render, screen } from "@testing-library/react";
3-
import { StageBadge } from "../StageBadge";
3+
import { StageBadge } from "./StageBadge";
44

55
describe("StageBadge", () => {
66
it("renders stage name", () => {

src/components/__tests__/StagePin.test.tsx renamed to src/components/StagePin.test.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { describe, expect, it, vi, beforeEach } from "vitest";
22
import { render, screen } from "@testing-library/react";
3-
import { StagePin } from "../StagePin";
3+
import { StagePin } from "./StagePin";
44
import * as useStageQueryModule from "@/hooks/queries/stages/useStageQuery";
55

6+
type StageQueryResult = ReturnType<typeof useStageQueryModule.useStageQuery>;
7+
68
vi.mock("@/hooks/queries/stages/useStageQuery");
79

810
describe("StagePin", () => {
@@ -15,7 +17,7 @@ describe("StagePin", () => {
1517
data: { id: "1", name: "Main Stage", color: "#ff0000", archived: false },
1618
isLoading: false,
1719
error: null,
18-
} as any);
20+
} as StageQueryResult);
1921

2022
render(<StagePin stageId="1" />);
2123
expect(screen.getByText("Main Stage")).toBeInTheDocument();
@@ -26,7 +28,7 @@ describe("StagePin", () => {
2628
data: { id: "1", name: "Main Stage", color: "#ff0000", archived: false },
2729
isLoading: false,
2830
error: null,
29-
} as any);
31+
} as StageQueryResult);
3032

3133
const { container } = render(<StagePin stageId="1" />);
3234
const icon = container.querySelector("svg");
@@ -38,7 +40,7 @@ describe("StagePin", () => {
3840
data: null,
3941
isLoading: false,
4042
error: null,
41-
} as any);
43+
} as StageQueryResult);
4244

4345
const { container } = render(<StagePin stageId="1" />);
4446
expect(container.firstChild).toBeNull();
@@ -49,7 +51,7 @@ describe("StagePin", () => {
4951
data: null,
5052
isLoading: false,
5153
error: null,
52-
} as any);
54+
} as StageQueryResult);
5355

5456
const { container } = render(<StagePin stageId={null} />);
5557
expect(container.firstChild).toBeNull();
@@ -60,7 +62,7 @@ describe("StagePin", () => {
6062
data: null,
6163
isLoading: true,
6264
error: null,
63-
} as any);
65+
} as unknown as StageQueryResult);
6466

6567
const { container } = render(<StagePin stageId="1" />);
6668
expect(container.firstChild).toBeNull();
@@ -71,7 +73,7 @@ describe("StagePin", () => {
7173
data: { id: "1", name: "Main Stage", color: "#ff0000", archived: false },
7274
isLoading: false,
7375
error: null,
74-
} as any);
76+
} as StageQueryResult);
7577

7678
const { container } = render(<StagePin stageId="1" />);
7779
const wrapper = container.querySelector("div");
@@ -83,7 +85,7 @@ describe("StagePin", () => {
8385
data: { id: "1", name: "Main Stage", color: "#ff0000", archived: false },
8486
isLoading: false,
8587
error: null,
86-
} as any);
88+
} as StageQueryResult);
8789

8890
const { container } = render(<StagePin stageId="1" />);
8991
const icon = container.querySelector("svg");
@@ -95,7 +97,7 @@ describe("StagePin", () => {
9597
data: { id: "1", name: "Main Stage", color: "#ff0000", archived: false },
9698
isLoading: false,
9799
error: null,
98-
} as any);
100+
} as StageQueryResult);
99101

100102
const { container } = render(<StagePin stageId="1" />);
101103
const text = container.querySelector("span");
@@ -112,7 +114,7 @@ describe("StagePin", () => {
112114
},
113115
isLoading: false,
114116
error: null,
115-
} as any);
117+
} as StageQueryResult);
116118

117119
render(<StagePin stageId="2" />);
118120
expect(screen.getByText("Electronic Stage")).toBeInTheDocument();

src/components/ui/__tests__/badge.test.tsx renamed to src/components/ui/badge.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from "vitest";
22
import { render, screen } from "@testing-library/react";
3-
import { Badge } from "../badge";
3+
import { Badge } from "./badge";
44

55
describe("Badge", () => {
66
it("renders children content", () => {

src/components/ui/__tests__/button.test.tsx renamed to src/components/ui/button.test.tsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { describe, expect, it, vi } from "vitest";
22
import { render, screen } from "@testing-library/react";
33
import userEvent from "@testing-library/user-event";
4-
import { Button } from "../button";
4+
import { Button } from "./button";
55

66
describe("Button", () => {
77
it("renders children content", () => {
88
render(<Button>Click me</Button>);
9-
expect(screen.getByRole("button", { name: "Click me" })).toBeInTheDocument();
9+
expect(
10+
screen.getByRole("button", { name: "Click me" }),
11+
).toBeInTheDocument();
1012
});
1113

1214
it("renders with default variant", () => {
@@ -28,7 +30,9 @@ describe("Button", () => {
2830
});
2931

3032
it("renders with secondary variant", () => {
31-
const { container } = render(<Button variant="secondary">Secondary</Button>);
33+
const { container } = render(
34+
<Button variant="secondary">Secondary</Button>,
35+
);
3236
const button = container.querySelector("button");
3337
expect(button).toHaveClass("bg-secondary", "text-secondary-foreground");
3438
});
@@ -86,13 +90,19 @@ describe("Button", () => {
8690
it("does not trigger click when disabled", async () => {
8791
const user = userEvent.setup();
8892
const handleClick = vi.fn();
89-
render(<Button disabled onClick={handleClick}>Disabled</Button>);
93+
render(
94+
<Button disabled onClick={handleClick}>
95+
Disabled
96+
</Button>,
97+
);
9098
await user.click(screen.getByRole("button"));
9199
expect(handleClick).not.toHaveBeenCalled();
92100
});
93101

94102
it("applies custom className", () => {
95-
const { container } = render(<Button className="custom-class">Custom</Button>);
103+
const { container } = render(
104+
<Button className="custom-class">Custom</Button>,
105+
);
96106
const button = container.querySelector("button");
97107
expect(button).toHaveClass("custom-class");
98108
});
@@ -111,7 +121,11 @@ describe("Button", () => {
111121
});
112122

113123
it("passes through HTML attributes", () => {
114-
render(<Button type="submit" data-testid="submit-btn">Submit</Button>);
124+
render(
125+
<Button type="submit" data-testid="submit-btn">
126+
Submit
127+
</Button>,
128+
);
115129
const button = screen.getByTestId("submit-btn");
116130
expect(button).toHaveAttribute("type", "submit");
117131
});
@@ -122,7 +136,11 @@ describe("Button", () => {
122136
});
123137

124138
it("combines variant and size classes", () => {
125-
const { container } = render(<Button variant="destructive" size="lg">Large Delete</Button>);
139+
const { container } = render(
140+
<Button variant="destructive" size="lg">
141+
Large Delete
142+
</Button>,
143+
);
126144
const button = container.querySelector("button");
127145
expect(button).toHaveClass("bg-destructive");
128146
expect(button).toHaveClass("h-11", "px-8");
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
CardDescription,
88
CardContent,
99
CardFooter,
10-
} from "../card";
10+
} from "./card";
1111

1212
describe("Card", () => {
1313
it("renders children content", () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
22
import { renderHook, act, waitFor } from "@testing-library/react";
3-
import { useIsMobile } from "../use-mobile";
3+
import { useIsMobile } from "./use-mobile";
44

55
describe("useIsMobile", () => {
66
let matchMediaMock: {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it, afterEach, vi } from "vitest";
22
import { renderHook, act } from "@testing-library/react";
3-
import { useToast, toast } from "../use-toast";
3+
import { useToast, toast } from "./use-toast";
44

55
describe("useToast", () => {
66
afterEach(() => {

0 commit comments

Comments
 (0)