mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 03:49:31 +00:00
test: remove duplicate checkForUpdates tests from update-check-cov.test.ts (#2997)
Two tests in update-check-cov.test.ts were exact duplicates of tests in update-check.test.ts: - "skips when recently checked successfully" duplicated "should skip fetch when last successful check was recent" - "does not skip when checked timestamp is old (>1h)" duplicated "should fetch when last successful check is older than 1 hour" Also removed the now-unused writeUpdateChecked helper function. Co-authored-by: spawn-qa-bot <qa@openrouter.ai> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
This commit is contained in:
parent
a7f3e9da82
commit
665780b6b2
1 changed files with 0 additions and 27 deletions
|
|
@ -28,14 +28,6 @@ function writeUpdateFailed(timestamp: number) {
|
|||
fs.writeFileSync(path.join(dir, ".update-failed"), String(timestamp));
|
||||
}
|
||||
|
||||
function writeUpdateChecked(timestamp: number) {
|
||||
const dir = path.join(process.env.HOME || "/tmp", ".config", "spawn");
|
||||
fs.mkdirSync(dir, {
|
||||
recursive: true,
|
||||
});
|
||||
fs.writeFileSync(path.join(dir, ".update-checked"), String(timestamp));
|
||||
}
|
||||
|
||||
describe("update-check.ts coverage", () => {
|
||||
let originalEnv: NodeJS.ProcessEnv;
|
||||
let consoleSpy: ReturnType<typeof spyOn>;
|
||||
|
|
@ -75,14 +67,6 @@ describe("update-check.ts coverage", () => {
|
|||
await checkForUpdates();
|
||||
expect(global.fetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("skips when recently checked successfully", async () => {
|
||||
writeUpdateChecked(Date.now()); // checked just now
|
||||
global.fetch = mock(async () => new Response("1.0.0"));
|
||||
const { checkForUpdates } = await import("../update-check");
|
||||
await checkForUpdates();
|
||||
expect(global.fetch).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
// ── checkForUpdates when up to date ────────────────────────────────────
|
||||
|
|
@ -136,17 +120,6 @@ describe("update-check.ts coverage", () => {
|
|||
expect(global.fetch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not skip when checked timestamp is old (>1h)", async () => {
|
||||
writeUpdateChecked(Date.now() - 2 * 60 * 60 * 1000); // 2 hours ago
|
||||
|
||||
const { checkForUpdates } = await import("../update-check");
|
||||
const pkg = await import("../../package.json");
|
||||
global.fetch = mock(async () => new Response(pkg.version));
|
||||
await checkForUpdates();
|
||||
// Should proceed with network check — fetch was called
|
||||
expect(global.fetch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("handles NaN in .update-failed file", async () => {
|
||||
const dir = path.join(process.env.HOME || "/tmp", ".config", "spawn");
|
||||
fs.mkdirSync(dir, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue