mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 07:32:44 +00:00
perf(test): avoid importing update-check in startup suite
This commit is contained in:
@@ -9,11 +9,23 @@ vi.mock("./openclaw-root.js", () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("./update-check.js", async () => {
|
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 {
|
return {
|
||||||
...actual,
|
|
||||||
checkUpdateStatus: vi.fn(),
|
checkUpdateStatus: vi.fn(),
|
||||||
fetchNpmTagVersion: vi.fn(),
|
compareSemverStrings,
|
||||||
resolveNpmChannelTag: vi.fn(),
|
resolveNpmChannelTag: vi.fn(),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user