Skip to content

Commit 0046755

Browse files
authored
minor refactor for tests for readability (#1387)
1 parent adca404 commit 0046755

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

server/tests/unit/api/data.spec.ts

+5-15
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,10 @@ describe("Data API", () => {
6868
});
6969

7070
resolveQuerySpy.mockRestore();
71-
resolveQuerySpy = vi.spyOn(InfoExtract, "resolveVideoQuery").mockImplementation(
72-
() =>
73-
new Promise((resolve, reject) =>
74-
reject({
75-
name: "InvalidAddPreviewInputException",
76-
message: "error message",
77-
})
78-
)
79-
);
71+
resolveQuerySpy = vi.spyOn(InfoExtract, "resolveVideoQuery").mockRejectedValue({
72+
name: "InvalidAddPreviewInputException",
73+
message: "error message",
74+
});
8075

8176
await request(app)
8277
.get("/api/data/previewAdd")
@@ -93,12 +88,7 @@ describe("Data API", () => {
9388
resolveQuerySpy.mockRestore();
9489
resolveQuerySpy = vi
9590
.spyOn(InfoExtract, "resolveVideoQuery")
96-
.mockImplementation(
97-
() =>
98-
new Promise((resolve, reject) =>
99-
reject({ name: "OutOfQuotaException", message: "error message" })
100-
)
101-
);
91+
.mockRejectedValue({ name: "OutOfQuotaException", message: "error message" });
10292

10393
await request(app)
10494
.get("/api/data/previewAdd")

0 commit comments

Comments
 (0)