cli/pkg/cli/render_test.go
Claude 82ccd30fcc
refactor(ax): Pass 1 AX compliance sweep — banned imports, naming, tests
- Remove banned imports (fmt, log, errors, os, strings, path/filepath,
  encoding/json) from all cmd/ packages; replace with core.* primitives
  and cli.* wrappers
- Rename abbreviated variables (cfg→configuration, reg→registry,
  cmd→proc, c→toolCheck/checkBuilder, sb→builder, out→output,
  r→repo/reason, b→branchName) across config, doctor, pkgcmd, help
- Add usage-example comments to all exported functions in pkg/cli
  (strings.go, log.go, i18n.go)
- Add complete Good/Bad/Ugly test triads to all pkg/cli test files:
  new files for command, errors, frame_components, i18n, log, render,
  runtime, strings, utils; updated existing check, daemon, glyph,
  layout, output, ansi, commands, frame, prompt, stream, styles,
  tracker, tree

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 09:17:23 +01:00

48 lines
1.2 KiB
Go

package cli
import (
"strings"
"testing"
)
func TestCompositeRender_Good(t *testing.T) {
UseRenderFlat()
composite := Layout("HCF")
composite.H("Header content").C("Body content").F("Footer content")
output := composite.String()
if !strings.Contains(output, "Header content") {
t.Errorf("Render flat: expected 'Header content' in output, got %q", output)
}
if !strings.Contains(output, "Body content") {
t.Errorf("Render flat: expected 'Body content' in output, got %q", output)
}
}
func TestCompositeRender_Bad(t *testing.T) {
// Rendering an empty composite should not panic and return empty string.
composite := Layout("HCF")
output := composite.String()
if output != "" {
t.Errorf("Empty composite render: expected empty string, got %q", output)
}
}
func TestCompositeRender_Ugly(t *testing.T) {
// RenderSimple and RenderBoxed styles add separators between sections.
UseRenderSimple()
defer UseRenderFlat()
composite := Layout("HCF")
composite.H("top").C("middle").F("bottom")
output := composite.String()
if output == "" {
t.Error("RenderSimple: expected non-empty output")
}
UseRenderBoxed()
output = composite.String()
if output == "" {
t.Error("RenderBoxed: expected non-empty output")
}
}