perf(test): avoid importing update-check in startup suite

This commit is contained in:
Peter Steinberger
2026-02-15 01:24:20 +00:00
parent b78bfd5213
commit e3d5fff264

View File

@@ -9,11 +9,23 @@ vi.mock("./openclaw-root.js", () => ({
}));
vi.mock("./update-check.js", async () => {
const actual = await vi.importActual<typeof import("./update-check.js")>("./update-check.js");
const parse = (value: string) => value.split(".").map((part) => Number.parseInt(part, 10));
const compareSemverStrings = (a: string, b: string) => {
const left = parse(a);
const right = parse(b);
for (let idx = 0; idx < 3; idx += 1) {
const l = left[idx] ?? 0;
const r = right[idx] ?? 0;
if (l !== r) {
return l < r ? -1 : 1;
}
}
return 0;
};
return {
...actual,
checkUpdateStatus: vi.fn(),
fetchNpmTagVersion: vi.fn(),
compareSemverStrings,
resolveNpmChannelTag: vi.fn(),
};
});