mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 22:04:30 +00:00
test: dedupe and optimize test suites
This commit is contained in:
@@ -12,6 +12,10 @@ vi.mock("./backoff.js", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
function createRuntime() {
|
||||
return { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
|
||||
}
|
||||
|
||||
describe("waitForTransportReady", () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
@@ -22,7 +26,7 @@ describe("waitForTransportReady", () => {
|
||||
});
|
||||
|
||||
it("returns when the check succeeds and logs after the delay", async () => {
|
||||
const runtime = { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
|
||||
const runtime = createRuntime();
|
||||
let attempts = 0;
|
||||
const readyPromise = waitForTransportReady({
|
||||
label: "test transport",
|
||||
@@ -48,7 +52,7 @@ describe("waitForTransportReady", () => {
|
||||
});
|
||||
|
||||
it("throws after the timeout", async () => {
|
||||
const runtime = { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
|
||||
const runtime = createRuntime();
|
||||
const waitPromise = waitForTransportReady({
|
||||
label: "test transport",
|
||||
timeoutMs: 110,
|
||||
@@ -65,7 +69,7 @@ describe("waitForTransportReady", () => {
|
||||
});
|
||||
|
||||
it("returns early when aborted", async () => {
|
||||
const runtime = { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
|
||||
const runtime = createRuntime();
|
||||
const controller = new AbortController();
|
||||
controller.abort();
|
||||
await waitForTransportReady({
|
||||
|
||||
Reference in New Issue
Block a user