Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

pi/agent/skills/optional/quickshell/bin/test/qs-version.test.mjs

Raw
// qs-version.test.mjs
// Run: node --test bin/test/qs-version.test.mjs

import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { dirname, join } from "node:path";
import { test } from "node:test";
import { fileURLToPath } from "node:url";

const __dirname = dirname(fileURLToPath(import.meta.url));
const BIN = join(__dirname, "..", "qs-version.mjs");

test("qs-version prints version + docs URL when qs is in PATH", () => {
	// We rely on the system `qs` being installed (it's in /usr/bin on this box).
	const result = spawnSync("node", [BIN], { encoding: "utf8" });
	assert.equal(result.status, 0, `stderr: ${result.stderr}`);
	// Output must contain "Quickshell" (or "quickshell"), a version, and a docs URL.
	assert.match(
		result.stdout,
		/Quickshell\s+\d+\.\d+\.\d+/i,
		"must print version",
	);
	assert.match(
		result.stdout,
		/https?:\/\/quickshell\.org\/docs\/v\d+\.\d+\.\d+\//,
		"must print docs URL",
	);
	// The docs URL must match the version line.
	const versionMatch = result.stdout.match(/(\d+\.\d+\.\d+)/);
	assert.ok(versionMatch, "must find a version");
	assert.ok(
		result.stdout.includes(`/docs/v${versionMatch[1]}/`),
		`docs URL must include /docs/v${versionMatch[1]}/`,
	);
});

test("qs-version exit code 0 on success", () => {
	const result = spawnSync("node", [BIN], { encoding: "utf8" });
	assert.equal(result.status, 0);
});

test("qs-version output is 2-3 lines", () => {
	const result = spawnSync("node", [BIN], { encoding: "utf8" });
	const lines = result.stdout.trim().split("\n");
	assert.ok(
		lines.length >= 2 && lines.length <= 3,
		`got ${lines.length} lines: ${result.stdout}`,
	);
});