修复 TypeScript 基线并补齐测试类型
This commit is contained in:
@@ -20,7 +20,7 @@ beforeEach(() => {
|
||||
|
||||
describe("POST /api/blindbox/draw", () => {
|
||||
it("draws a random idea", async () => {
|
||||
prismaMock.$transaction.mockImplementation(async (fn: (tx: unknown) => Promise<unknown>) => {
|
||||
prismaMock.$transaction.mockImplementation((async (fn: unknown) => {
|
||||
const tx = {
|
||||
blindBoxIdea: {
|
||||
findMany: vi.fn().mockResolvedValue([{ id: "idea-1" }]),
|
||||
@@ -34,8 +34,8 @@ describe("POST /api/blindbox/draw", () => {
|
||||
}),
|
||||
},
|
||||
};
|
||||
return fn(tx);
|
||||
});
|
||||
return (fn as (txArg: typeof tx) => Promise<unknown>)(tx);
|
||||
}) as never);
|
||||
|
||||
const req = createRequest("/api/blindbox/draw", {
|
||||
method: "POST",
|
||||
@@ -52,7 +52,7 @@ describe("POST /api/blindbox/draw", () => {
|
||||
});
|
||||
|
||||
it("returns 404 when pool is empty", async () => {
|
||||
prismaMock.$transaction.mockImplementation(async (fn: (tx: unknown) => Promise<unknown>) => {
|
||||
prismaMock.$transaction.mockImplementation((async (fn: unknown) => {
|
||||
const tx = {
|
||||
blindBoxIdea: {
|
||||
findMany: vi.fn().mockResolvedValue([]),
|
||||
@@ -60,8 +60,8 @@ describe("POST /api/blindbox/draw", () => {
|
||||
findUnique: vi.fn(),
|
||||
},
|
||||
};
|
||||
return fn(tx);
|
||||
});
|
||||
return (fn as (txArg: typeof tx) => Promise<unknown>)(tx);
|
||||
}) as never);
|
||||
|
||||
const req = createRequest("/api/blindbox/draw", {
|
||||
method: "POST",
|
||||
@@ -72,7 +72,7 @@ describe("POST /api/blindbox/draw", () => {
|
||||
});
|
||||
|
||||
it("returns 409 on race condition (count=0)", async () => {
|
||||
prismaMock.$transaction.mockImplementation(async (fn: (tx: unknown) => Promise<unknown>) => {
|
||||
prismaMock.$transaction.mockImplementation((async (fn: unknown) => {
|
||||
const tx = {
|
||||
blindBoxIdea: {
|
||||
findMany: vi.fn().mockResolvedValue([{ id: "idea-1" }]),
|
||||
@@ -80,8 +80,8 @@ describe("POST /api/blindbox/draw", () => {
|
||||
findUnique: vi.fn(),
|
||||
},
|
||||
};
|
||||
return fn(tx);
|
||||
});
|
||||
return (fn as (txArg: typeof tx) => Promise<unknown>)(tx);
|
||||
}) as never);
|
||||
|
||||
const req = createRequest("/api/blindbox/draw", {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user