mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
13 lines
528 B
TypeScript
13 lines
528 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { getPiUserAgent } from "../src/utils/pi-user-agent.ts";
|
|
|
|
describe("getPiUserAgent", () => {
|
|
it("formats the user agent expected by pi.dev", () => {
|
|
const runtime = process.versions.bun ? `bun/${process.versions.bun}` : `node/${process.version}`;
|
|
const userAgent = getPiUserAgent("1.2.3");
|
|
|
|
expect(userAgent).toBe(`pi/1.2.3 (${process.platform}; ${runtime}; ${process.arch})`);
|
|
expect(userAgent).toMatch(/^pi\/[^\s()]+ \([^;()]+;\s*[^;()]+;\s*[^()]+\)$/);
|
|
});
|
|
});
|