import { describe, expect, test } from "bun:test";
import { generateMbsyncConfig } from "./sync";

describe("generateMbsyncConfig", () => {
	test("generates valid mbsyncrc for a single IMAP account", () => {
		const config = generateMbsyncConfig({
			id: "personal",
			host: "mail.example.com",
			user: "user@example.com",
			passCmd: "cat ~/.mail-pass",
			sslType: "IMAPS",
			mailDir: "/home/user/Mail/personal",
		});

		expect(config).toContain("IMAPAccount personal");
		expect(config).toContain("Host mail.example.com");
		expect(config).toContain("User user@example.com");
		expect(config).toContain('PassCmd "cat ~/.mail-pass"');
		expect(config).toContain("SSLType IMAPS");
		expect(config).toContain("Path /home/user/Mail/personal/");
		expect(config).toContain("Inbox /home/user/Mail/personal/Inbox");
		expect(config).toContain("Channel personal");
		expect(config).toContain("Far :personal-remote:");
		expect(config).toContain("Near :personal-local:");
		expect(config).toContain("Patterns *");
		expect(config).toContain("Create Both");
		expect(config).toContain("SyncState *");
	});
});
