lint: fix biome issues in new test files and helpers
This commit is contained in:
1 parent
99eb3af17b
commit
93862c2275
41 files changed
+488
-314
No files matched your search
@@ -27,6 +27,7 @@ vi.mock("next/cache", () => ({
|
||||
unstable_cache: (fn: any) => fn,
|
||||
}));
|
||||
|
||||
import { WebsiteRareValueCategories, WebsiteRareValues } from "@/lib/db";
|
||||
import {
|
||||
createCategory,
|
||||
createValue,
|
||||
@@ -35,10 +36,6 @@ import {
|
||||
updateCategory,
|
||||
updateValue,
|
||||
} from "./admin-rare-values";
|
||||
import {
|
||||
WebsiteRareValueCategories,
|
||||
WebsiteRareValues,
|
||||
} from "@/lib/db";
|
||||
|
||||
function form(data: Record<string, string>): FormData {
|
||||
const fd = new FormData();
|
||||
@@ -86,7 +83,7 @@ describe("createCategory", () => {
|
||||
});
|
||||
|
||||
it("swallows insert errors and still revalidates", async () => {
|
||||
fakeDbConfig.fail = (kind: string) => (kind === "insert" ? true : false);
|
||||
fakeDbConfig.fail = (kind: string) => kind === "insert";
|
||||
await createCategory(form({ name: "A", badge: "B" }));
|
||||
expect(mockRevalidatePath).toHaveBeenCalledWith("/admin/rare-values");
|
||||
});
|
||||
@@ -116,7 +113,7 @@ describe("deleteCategory", () => {
|
||||
});
|
||||
|
||||
it("swallows DB errors and still revalidates", async () => {
|
||||
fakeDbConfig.fail = (kind: string) => (kind === "delete" ? true : false);
|
||||
fakeDbConfig.fail = (kind: string) => kind === "delete";
|
||||
await deleteCategory(form({ id: "3" }));
|
||||
expect(mockRevalidatePath).toHaveBeenCalledWith("/admin/rare-values");
|
||||
});
|
||||
@@ -152,9 +149,7 @@ describe("createValue", () => {
|
||||
|
||||
it("returns early when categoryId, name or furnitureIcon is missing", async () => {
|
||||
await createValue(form({ name: "X", furnitureIcon: "x.png" }));
|
||||
await createValue(
|
||||
form({ categoryId: "1", furnitureIcon: "x.png" }),
|
||||
);
|
||||
await createValue(form({ categoryId: "1", furnitureIcon: "x.png" }));
|
||||
await createValue(form({ categoryId: "1", name: "X" }));
|
||||
expect(fakeDbConfig.ops).toHaveLength(0);
|
||||
expect(mockRevalidatePath).not.toHaveBeenCalled();
|
||||
@@ -179,7 +174,7 @@ describe("createValue", () => {
|
||||
});
|
||||
|
||||
it("swallows insert errors and still revalidates", async () => {
|
||||
fakeDbConfig.fail = (kind: string) => (kind === "insert" ? true : false);
|
||||
fakeDbConfig.fail = (kind: string) => kind === "insert";
|
||||
await createValue(
|
||||
form({ categoryId: "1", name: "X", furnitureIcon: "x.png" }),
|
||||
);
|
||||
@@ -203,7 +198,7 @@ describe("deleteValue", () => {
|
||||
});
|
||||
|
||||
it("swallows delete errors and still revalidates", async () => {
|
||||
fakeDbConfig.fail = (kind: string) => (kind === "delete" ? true : false);
|
||||
fakeDbConfig.fail = (kind: string) => kind === "delete";
|
||||
await deleteValue(form({ id: "4" }));
|
||||
expect(mockRevalidatePath).toHaveBeenCalledWith("/admin/rare-values");
|
||||
});
|
||||
@@ -231,7 +226,7 @@ describe("updateCategory", () => {
|
||||
});
|
||||
|
||||
it("swallows update errors and still revalidates", async () => {
|
||||
fakeDbConfig.fail = (kind: string) => (kind === "update" ? true : false);
|
||||
fakeDbConfig.fail = (kind: string) => kind === "update";
|
||||
await updateCategory(form({ id: "1", name: "X", badge: "B" }));
|
||||
expect(mockRevalidatePath).toHaveBeenCalledWith("/admin/rare-values");
|
||||
});
|
||||
@@ -292,8 +287,8 @@ describe("updateValue", () => {
|
||||
});
|
||||
|
||||
it("swallows update errors and still revalidates", async () => {
|
||||
fakeDbConfig.fail = (kind: string) => (kind === "update" ? true : false);
|
||||
fakeDbConfig.fail = (kind: string) => kind === "update";
|
||||
await updateValue(form({ id: "1", name: "X", furnitureIcon: "x.png" }));
|
||||
expect(mockRevalidatePath).toHaveBeenCalledWith("/admin/rare-values");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user