MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestEventDoneFlushesStreamingThroughGlamour

Function TestEventDoneFlushesStreamingThroughGlamour

internal/tui/tui_test.go:2478–2490  ·  view source on GitHub ↗

TestEventDoneFlushesStreamingThroughGlamour: EventDone moves raw streamed text into the committed scroll via the Markdown renderer and empties the streaming buffer. After Done, scroll contains the rendered block and the streaming buffer is empty.

(t *testing.T)

Source from the content-addressed store, hash-verified

2476// stripANSI removes CSI escape sequences (`\x1b[…m`) so tests can match the
2477// visible text through glamour's per-word styling, which splits "foo bar" into
2478// `<span>foo</span> <span>bar</span>` and breaks a naive Contains("foo bar").
2479func stripANSI(s string) string {
2480 var b strings.Builder
2481 for i := 0; i < len(s); i++ {
2482 if s[i] == 0x1b && i+1 < len(s) && s[i+1] == '[' {
2483 for j := i + 2; j < len(s); j++ {
2484 if s[j] >= 0x40 && s[j] <= 0x7e {
2485 i = j
2486 break
2487 }
2488 }
2489 continue
2490 }
2491 b.WriteByte(s[i])
2492 }
2493 return b.String()

Callers

nothing calls this directly

Calls 4

newTestModelFunction · 0.85
stripANSIFunction · 0.85
handleStreamMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected