mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-25 17:02:46 +00:00
test(whatsapp): preserve session exports in login coverage
This commit is contained in:
committed by
Peter Steinberger
parent
dad6018230
commit
e87a64f8d0
@@ -1,6 +1,5 @@
|
||||
import { rmSync } from "node:fs";
|
||||
import fs from "node:fs/promises";
|
||||
import { DisconnectReason } from "@whiskeysockets/baileys";
|
||||
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { loginWeb } from "./login.js";
|
||||
import {
|
||||
@@ -38,7 +37,8 @@ vi.mock("openclaw/plugin-sdk/config-runtime", async () => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./session.js", () => {
|
||||
vi.mock("./session.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("./session.js")>("./session.js");
|
||||
const authDir = resolveTestAuthDir();
|
||||
const sockA = { ws: { close: vi.fn() } };
|
||||
const sockB = { ws: { close: vi.fn() } };
|
||||
@@ -53,6 +53,7 @@ vi.mock("./session.js", () => {
|
||||
);
|
||||
const waitForCredsSaveQueueWithTimeout = vi.fn(async () => {});
|
||||
return {
|
||||
...actual,
|
||||
createWaSocket,
|
||||
waitForWaConnection,
|
||||
formatError,
|
||||
@@ -128,7 +129,7 @@ describe("loginWeb coverage", () => {
|
||||
|
||||
it("clears creds and throws when logged out", async () => {
|
||||
waitForWaConnectionMock.mockRejectedValueOnce({
|
||||
output: { statusCode: DisconnectReason.loggedOut },
|
||||
output: { statusCode: 401 },
|
||||
});
|
||||
|
||||
await expect(loginWeb(false, waitForWaConnectionMock as never)).rejects.toThrow(
|
||||
|
||||
Reference in New Issue
Block a user