package sanitize

import "testing"

func TestText_StripsBillingHeader(t *testing.T) {
	in := "x-anthropic-billing-header: cc_version=1.0.8; cch=abc123\nhello world"
	out := Text(in)
	if out != "hello world" {
		t.Errorf("got %q, want %q", out, "hello world")
	}
}

func TestText_StripsTelemetryTokens(t *testing.T) {
	in := "request: cc_version=2.3; cc_entrypoint=cli; cch=deadbeef the rest"
	out := Text(in)
	if got, want := out, "request: the rest"; got != want {
		t.Errorf("got %q, want %q", got, want)
	}
}

func TestText_ReplacesClaudeCodeBranding(t *testing.T) {
	cases := map[string]string{
		"You are Claude Code, Anthropic's official CLI for Claude.":     "You are Cursor, Cursor AI assistant.",
		"Powered by Anthropic.":                                         "Powered by Cursor.",
		"Visit https://claude.ai/docs or https://anthropic.com for more": "Visit https://cursor.sh/docs or https://cursor.com for more",
	}
	for in, want := range cases {
		if got := Text(in); got != want {
			t.Errorf("Text(%q)\n got:  %q\n want: %q", in, got, want)
		}
	}
}

func TestText_EmptyStringPassesThrough(t *testing.T) {
	if got := Text(""); got != "" {
		t.Errorf("Text(\"\") = %q, want empty", got)
	}
}

func TestText_IsIdempotent(t *testing.T) {
	in := "Claude Code says hi at anthropic.com"
	first := Text(in)
	second := Text(first)
	if first != second {
		t.Errorf("sanitize is not idempotent:\n  first:  %q\n  second: %q", first, second)
	}
}
