test(frontend): simplify fetch mock signatures in auth tests
This commit is contained in:
1 parent
02ff53229c
commit
568112b85a
1 file changed
+6
-8
@@ -440,7 +440,7 @@ describe("auth and user list wiring", () => {
|
|||||||
it("logs in and updates the auth UI", async () => {
|
it("logs in and updates the auth UI", async () => {
|
||||||
await import("../src/main");
|
await import("../src/main");
|
||||||
|
|
||||||
globalThis.fetch = vi.fn(async (url: any, opts?: any) => {
|
globalThis.fetch = vi.fn(async (url: any) => {
|
||||||
const u = String(url);
|
const u = String(url);
|
||||||
if (u.includes("/api/auth/login")) {
|
if (u.includes("/api/auth/login")) {
|
||||||
return {
|
return {
|
||||||
@@ -470,13 +470,11 @@ describe("auth and user list wiring", () => {
|
|||||||
it("toggles the user list visibility", async () => {
|
it("toggles the user list visibility", async () => {
|
||||||
await import("../src/main");
|
await import("../src/main");
|
||||||
|
|
||||||
globalThis.fetch = vi
|
globalThis.fetch = vi.fn().mockResolvedValue({
|
||||||
.fn()
|
ok: true,
|
||||||
.mockResolvedValue({
|
json: async () => ({ authenticated: false, entries: [] }),
|
||||||
ok: true,
|
text: async () => "",
|
||||||
json: async () => ({ authenticated: false, entries: [] }),
|
}) as any;
|
||||||
text: async () => "",
|
|
||||||
}) as any;
|
|
||||||
|
|
||||||
document.dispatchEvent(new Event("DOMContentLoaded"));
|
document.dispatchEvent(new Event("DOMContentLoaded"));
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user