File size: 603 Bytes
9509f5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { describe, expect, it } from "vitest";
import { appVersion } from "@/modules/appInfo";

describe("appVersion", () => {
  it("appends the commit hash as semver build metadata when the build had one", () => {
    // vitest.config.ts defines VITE_COMMIT_SHORT_HASH as "test-hash".
    expect(appVersion).toMatch(/^\d{4}\.\d{1,2}\.\d{1,2}\+test-hash$/);
  });

  it("never leaves a dangling separator", () => {
    // A build context without a usable git repository yields an empty hash, and
    // "1.2.3+" is not a valid version string.
    expect(appVersion.endsWith("+")).toBe(false);
  });
});