Files
edgeever/packages/shared/src/version.test.mjs
T
tianma-if e8ed6b1019 fix(desktop): allow auto-restart even when the instance is behind
Stop holding downloaded desktop updates until the connected instance
catches up. When the client is newer, system info shows a small hint
that some features may not work yet and that the instance can update
automatically each day or be updated manually.
2026-09-11 10:36:36 +08:00

25 lines
1.3 KiB
JavaScript

import { describe, expect, test } from "bun:test";
import { isClientAheadOfInstance, isVersionOutdated } from "./version";
describe("release version comparison", () => {
test("compares semantic release components and ignores build metadata", () => {
expect(isVersionOutdated("1.6.49+12", "1.6.50")).toBe(true);
expect(isVersionOutdated("1.6.50+3", "1.6.50")).toBe(false);
expect(isVersionOutdated("1.6.50-beta.2", "1.6.50-beta.10")).toBe(true);
expect(isVersionOutdated("1.6.50-beta.10", "1.6.50")).toBe(true);
expect(isVersionOutdated("1.6.50", "1.6.50-beta.10")).toBe(false);
});
test("treats the client as ahead only when it is newer than a known instance", () => {
expect(isClientAheadOfInstance("1.66.0", "1.65.1")).toBe(true);
expect(isClientAheadOfInstance("v1.66.0", "v1.65.1")).toBe(true);
expect(isClientAheadOfInstance("1.65.1+4", "1.65.1")).toBe(false);
expect(isClientAheadOfInstance("1.65.1", "1.65.1")).toBe(false);
expect(isClientAheadOfInstance("1.64.0", "1.65.1")).toBe(false);
expect(isClientAheadOfInstance("1.66.0", null)).toBe(false);
expect(isClientAheadOfInstance("1.66.0", "")).toBe(false);
expect(isClientAheadOfInstance("1.66.0", "local")).toBe(false);
expect(isClientAheadOfInstance(null, "1.65.1")).toBe(false);
});
});