package core

import "testing"

func TestStripANSI(t *testing.T) {
	t.Run("golden: color SGR codes", func(t *testing.T) {
		got := StripANSI("\x1b[31mhola\x1b[0m mundo")
		want := "hola mundo"
		if got != want {
			t.Errorf("got %q, want %q", got, want)
		}
	})

	t.Run("edge OSC titulo de ventana", func(t *testing.T) {
		got := StripANSI("\x1b]0;mi titulo\x07texto")
		want := "texto"
		if got != want {
			t.Errorf("got %q, want %q", got, want)
		}
	})

	t.Run("edge movimientos de cursor", func(t *testing.T) {
		got := StripANSI("linea1\x1b[2K\x1b[1Glinea2")
		want := "linea1linea2"
		if got != want {
			t.Errorf("got %q, want %q", got, want)
		}
	})

	t.Run("edge string sin escapes preserva saltos de linea", func(t *testing.T) {
		got := StripANSI("plano\ncon\nlineas")
		want := "plano\ncon\nlineas"
		if got != want {
			t.Errorf("got %q, want %q", got, want)
		}
	})

	t.Run("edge string vacio", func(t *testing.T) {
		got := StripANSI("")
		want := ""
		if got != want {
			t.Errorf("got %q, want %q", got, want)
		}
	})

	t.Run("edge preserva tabs", func(t *testing.T) {
		got := StripANSI("a\tb")
		want := "a\tb"
		if got != want {
			t.Errorf("got %q, want %q", got, want)
		}
	})
}
