package format
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestColorize_TagName(t *testing.T) {
result := Colorize("
text
")
// Should contain ANSI codes
assert.Contains(t, result, "\033[")
// Tag names should be colored, text should not have color wrapping
assert.Contains(t, result, "text")
}
func TestColorize_ACNamespace(t *testing.T) {
result := Colorize(``)
// ac: tags should use magenta
assert.Contains(t, result, magenta+"ac:structured-macro")
}
func TestColorize_RINamespace(t *testing.T) {
result := Colorize(``)
// ri: tags should use cyan
assert.Contains(t, result, cyan+"ri:user")
}
func TestColorize_HTMLTag(t *testing.T) {
result := Colorize("hello
")
// Standard HTML tags should use blue
assert.Contains(t, result, blue+"p")
}
func TestColorize_Attributes(t *testing.T) {
result := Colorize(`go`)
// Attribute names should be yellow
assert.Contains(t, result, yellow+"ac:name")
// Attribute values should be green
assert.Contains(t, result, green+`"language"`)
}
func TestColorize_CDATA(t *testing.T) {
result := Colorize(``)
// CDATA should be gray
assert.Contains(t, result, gray+"")
}
func TestColorize_Comment(t *testing.T) {
result := Colorize(``)
assert.Contains(t, result, gray+"")
}
func TestColorize_PlainText(t *testing.T) {
result := Colorize("just text")
// No ANSI codes for plain text
assert.False(t, strings.Contains(result, "\033["))
}
func TestColorize_SelfClosingTag(t *testing.T) {
result := Colorize(`
`)
assert.Contains(t, result, gray+"/>")
}
func TestColorize_ComplexDocument(t *testing.T) {
input := `
Hello world
`
result := Colorize(input)
// Should not panic, should contain resets
assert.True(t, strings.Count(result, reset) > 0)
// Plain text "Hello " and "world" should be present without color wrapping
assert.Contains(t, result, "Hello ")
}