Luigit
repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

extensions/vcs-status/__tests__/vcs.test.ts

Raw
import { describe, expect, it } from "vitest";
import { __test } from "../index";

describe("vcs-status parsing", () => {
	it("labels detached git as HEAD", () => {
		const status = __test.parsePorcelain("# branch.head (detached)\n", false);
		expect(__test.gitLabel(status)).toBe("HEAD");
	});

	it("keeps git flags compact", () => {
		const status = __test.parsePorcelain(
			[
				"# branch.head main",
				"# branch.ab +2 -1",
				"# stash 1",
				"1 M. N... 100644 100644 100644 a a file.ts",
				"? new.ts",
			].join("\n"),
		);

		expect(__test.gitLabel(status)).toBe("main [$+?⇕]");
	});

	it("labels jj changes", () => {
		expect(
			__test.jjLabel({
				available: true,
				change: "abc123",
				bookmarks: "trunk",
				empty: true,
				conflict: false,
				divergent: true,
			}),
		).toBe("@ abc123 trunk ∅≈");
		expect(__test.jjLabel({ available: false })).toBe("?");
	});
});