chore: reorg tests
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user