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
@@ -80,7 +80,6 @@ vi.mock("@/lib/db", async () => {
|
||||
});
|
||||
|
||||
import { WebsiteWriteableBoxes } from "@/lib/db";
|
||||
import { PERMS } from "@/lib/permissions";
|
||||
import {
|
||||
createBox,
|
||||
deleteBox,
|
||||
@@ -106,9 +105,9 @@ beforeEach(() => {
|
||||
describe("createBox", () => {
|
||||
it("rejects callers without PAGES_EDIT", async () => {
|
||||
mockRequirePermission.mockRejectedValueOnce(new Error("denied"));
|
||||
await expect(createBox(fakeForm({ title: "Hi" }) as FormData)).rejects.toThrow(
|
||||
"denied",
|
||||
);
|
||||
await expect(
|
||||
createBox(fakeForm({ title: "Hi" }) as FormData),
|
||||
).rejects.toThrow("denied");
|
||||
expect(state.insertCalls).toHaveLength(0);
|
||||
});
|
||||
|
||||
@@ -166,15 +165,12 @@ describe("createBox", () => {
|
||||
isActive: "0",
|
||||
}) as FormData,
|
||||
);
|
||||
expect(
|
||||
(state.insertCalls.at(-1)?.values as Record<string, unknown>).position,
|
||||
).toBe(expected);
|
||||
expect(
|
||||
(state.insertCalls.at(-1)?.values as Record<string, unknown>).isActive,
|
||||
).toBe(false);
|
||||
expect(
|
||||
(state.insertCalls.at(-1)?.values as Record<string, unknown>).icon,
|
||||
).toBeNull();
|
||||
const lastInsert = state.insertCalls.at(-1);
|
||||
expect(lastInsert).toBeDefined();
|
||||
const vals = lastInsert?.values as Record<string, unknown>;
|
||||
expect(vals.position).toBe(expected);
|
||||
expect(vals.isActive).toBe(false);
|
||||
expect(vals.icon).toBeNull();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -267,7 +263,9 @@ describe("deleteBox", () => {
|
||||
|
||||
it("swallows a failed delete", async () => {
|
||||
state.deleteError = new Error("db down");
|
||||
await expect(deleteBox(fakeForm({ id: "1" }) as FormData)).resolves.toBeUndefined();
|
||||
await expect(
|
||||
deleteBox(fakeForm({ id: "1" }) as FormData),
|
||||
).resolves.toBeUndefined();
|
||||
expect(mockLogStaffActivity).not.toHaveBeenCalled();
|
||||
expect(mockRevalidatePath).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -282,7 +280,9 @@ describe("toggleBox", () => {
|
||||
it("activates when next is 1", async () => {
|
||||
await toggleBox(fakeForm({ id: "2", next: "1" }) as FormData);
|
||||
expect(state.updateCalls).toHaveLength(1);
|
||||
expect((state.updateCalls[0].values as Record<string, unknown>).isActive).toBe(true);
|
||||
expect(
|
||||
(state.updateCalls[0].values as Record<string, unknown>).isActive,
|
||||
).toBe(true);
|
||||
expect(mockLogStaffActivity).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
action: "writeable_box_toggle",
|
||||
@@ -294,7 +294,9 @@ describe("toggleBox", () => {
|
||||
|
||||
it("hides when next is anything but 1", async () => {
|
||||
await toggleBox(fakeForm({ id: "2", next: "0" }) as FormData);
|
||||
expect((state.updateCalls[0].values as Record<string, unknown>).isActive).toBe(false);
|
||||
expect(
|
||||
(state.updateCalls[0].values as Record<string, unknown>).isActive,
|
||||
).toBe(false);
|
||||
expect(mockLogStaffActivity).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
description: "Hid writeable box #2",
|
||||
@@ -304,8 +306,10 @@ describe("toggleBox", () => {
|
||||
|
||||
it("swallows a failed toggle", async () => {
|
||||
state.updateError = new Error("db down");
|
||||
await expect(toggleBox(fakeForm({ id: "2", next: "1" }) as FormData)).resolves.toBeUndefined();
|
||||
await expect(
|
||||
toggleBox(fakeForm({ id: "2", next: "1" }) as FormData),
|
||||
).resolves.toBeUndefined();
|
||||
expect(mockLogStaffActivity).not.toHaveBeenCalled();
|
||||
expect(mockRevalidatePath).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user