package services

// Pretty-printer tests for the variable-resolution layer (legalSourcePretty,
// ourSideDE/EN, patentNumberUPC). These live with submission_vars.go;
// they were relocated out of the docx engine test suite when the
// .docx renderer moved to pkg/docforge/docx (t-paliad-349 slice 1).

import "testing"

func TestLegalSourcePretty(t *testing.T) {
	tests := []struct {
		src, lang, want string
	}{
		{"DE.ZPO.276.1", "de", "§ 276 Abs. 1 ZPO"},
		{"DE.ZPO.276.1", "en", "Section 276(1) ZPO"},
		{"DE.ZPO.253", "de", "§ 253 ZPO"},
		{"DE.ZPO.253", "en", "Section 253 ZPO"},
		{"UPC.RoP.23.1", "de", "Regel 23.1 VerfO UPC"},
		{"UPC.RoP.23.1", "en", "Rule 23.1 RoP UPC"},
		{"UPC.RoP.198", "de", "Regel 198 VerfO UPC"},
		{"DE.PatG.83", "de", "§ 83 PatG"},
		{"EPC.123", "de", "Art. 123 EPÜ"},
		{"EPC.123", "en", "Art. 123 EPC"},
		{"FOO.BAR.123", "de", "FOO.BAR.123"},
		{"", "de", ""},
	}
	for _, tc := range tests {
		t.Run(tc.src+"/"+tc.lang, func(t *testing.T) {
			got := legalSourcePretty(tc.src, tc.lang)
			if got != tc.want {
				t.Errorf("legalSourcePretty(%q, %q) = %q, want %q", tc.src, tc.lang, got, tc.want)
			}
		})
	}
}

func TestOurSideTranslations(t *testing.T) {
	cases := []struct {
		in, wantDE, wantEN string
	}{
		{"claimant", "Klägerin", "Claimant"},
		{"defendant", "Beklagte", "Defendant"},
		{"court", "Gericht", "Court"},
		{"both", "Klägerin und Beklagte", "Claimant and Defendant"},
		{"", "", ""},
		{"unknown", "", ""},
	}
	for _, tc := range cases {
		t.Run(tc.in, func(t *testing.T) {
			if got := ourSideDE(tc.in); got != tc.wantDE {
				t.Errorf("ourSideDE(%q) = %q, want %q", tc.in, got, tc.wantDE)
			}
			if got := ourSideEN(tc.in); got != tc.wantEN {
				t.Errorf("ourSideEN(%q) = %q, want %q", tc.in, got, tc.wantEN)
			}
		})
	}
}

func TestPatentNumberUPC(t *testing.T) {
	tests := []struct {
		in, want string
	}{
		{"EP 1 234 567 B1", "EP 1 234 567 (B1)"},
		{"EP 4 056 049 A1", "EP 4 056 049 (A1)"},
		{"DE 10 2020 123 456 A1", "DE 10 2020 123 456 (A1)"},
		{"EP 1 234 567", "EP 1 234 567"},
		{"  EP 1 234 567 B1  ", "EP 1 234 567 (B1)"},
		{"", ""},
		{"WO/2023/123456", "WO/2023/123456"},
		{"EP 1 234 567 B12", "EP 1 234 567 B12"},
	}
	for _, tc := range tests {
		t.Run(tc.in, func(t *testing.T) {
			got := patentNumberUPC(tc.in)
			if got != tc.want {
				t.Errorf("patentNumberUPC(%q) = %q, want %q", tc.in, got, tc.want)
			}
		})
	}
}
