chore: reorg tests

This commit is contained in:
can1357
2026-07-27 16:43:53 +02:00
parent 137bad2c8b
commit d16a251777
80 changed files with 258 additions and 236 deletions
@@ -0,0 +1,28 @@
import { afterEach, describe, expect, it, vi } from "bun:test";
import { runUpdateCommand } from "../../src/cli/update-cli";
type FetchInput = string | URL | Request;
type FetchInit = RequestInit | BunFetchRequestInit;
describe("runUpdateCommand fetch cancellation", () => {
afterEach(() => {
vi.restoreAllMocks();
});
it("checks release metadata with a timeout signal", async () => {
let requestSignal: AbortSignal | undefined;
vi.spyOn(console, "log").mockImplementation(() => {});
const fetchStub = Object.assign(
async (_input: FetchInput, init?: FetchInit) => {
requestSignal = init?.signal ?? undefined;
return Response.json({ version: "999.0.0" });
},
{ preconnect: globalThis.fetch.preconnect },
);
vi.spyOn(globalThis, "fetch").mockImplementation(fetchStub);
await runUpdateCommand({ force: false, check: true });
expect(requestSignal).toBeInstanceOf(AbortSignal);
});
});