The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, test } from "@alchemy.run/test"; |
| 2 | import { _internal } from "../../src/Cli/checkVersion"; |
| 3 | |
| 4 | const { compareVersions } = _internal; |
| 5 | |
| 6 | describe("compareVersions", { tags: ["unit", "local"] }, () => { |
| 7 | test("orders prerelease numbers numerically, not lexically", () => { |
| 8 | expect(compareVersions("2.0.0-beta.68", "2.0.0-beta.67")).toBeGreaterThan(0); |
| 9 | expect(compareVersions("2.0.0-beta.9", "2.0.0-beta.10")).toBeLessThan(0); |
| 10 | }); |
| 11 | |
| 12 | test("release outranks its prereleases", () => { |
| 13 | expect(compareVersions("2.0.0", "2.0.0-rc.1")).toBeGreaterThan(0); |
| 14 | expect(compareVersions("2.0.0-rc.1", "2.0.0")).toBeLessThan(0); |
| 15 | }); |
| 16 | |
| 17 | test("core versions compare numerically", () => { |
| 18 | expect(compareVersions("0.93.7", "0.93.6")).toBeGreaterThan(0); |
| 19 | expect(compareVersions("0.93.7", "2.0.0-beta.1")).toBeLessThan(0); |
| 20 | }); |
| 21 | |
| 22 | test("equal versions compare as 0 (stale tag must not warn)", () => { |
| 23 | expect(compareVersions("2.0.0-beta.68", "2.0.0-beta.68")).toBe(0); |
| 24 | }); |
| 25 | |
| 26 | test("alphanumeric prerelease identifiers rank above numeric ones", () => { |
| 27 | expect(compareVersions("2.0.0-rc.1", "2.0.0-beta.99")).toBeGreaterThan(0); |
| 28 | expect(compareVersions("2.0.0-beta.1", "2.0.0-1")).toBeGreaterThan(0); |
| 29 | }); |
| 30 | }); |