29 lines
924 B
TypeScript
29 lines
924 B
TypeScript
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);
|
|
});
|
|
});
|