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

Function TestEntryRestoreRoundTrip

internal/tui/prompt_test.go:296–319  ·  view source on GitHub ↗

TestEntryRestoreRoundTrip: Entry()+Restore() fully recovers chip state: display text, spans, expanded Value(). Backs ↑/↓ history replay.

(t *testing.T)

Source from the content-addressed store, hash-verified

294// TestEntryRestoreRoundTrip: Entry()+Restore() fully recovers chip state:
295// display text, spans, expanded Value(). Backs ↑/↓ history replay.
296func TestEntryRestoreRoundTrip(t *testing.T) {
297 p := newChippablePrompt()
298 paste := makePaste(12)
299 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("pre ")})
300 p, _ = p.Update(pasteKey(paste))
301 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune(" post")})
302
303 entry := p.Entry()
304 wantDisplay := p.DisplayValue()
305 wantValue := p.Value()
306
307 q := newChippablePrompt()
308 q.Restore(entry)
309
310 if got := q.DisplayValue(); got != wantDisplay {
311 t.Fatalf("DisplayValue mismatch after Restore: %q vs %q", got, wantDisplay)
312 }
313 if got := q.Value(); got != wantValue {
314 t.Fatalf("Value mismatch after Restore")
315 }
316 if len(q.spans) != 1 {
317 t.Fatalf("expected 1 span after Restore, got %d", len(q.spans))
318 }
319}
320
321// TestResetClearsChips: Reset empties store and spans, leaving only new text.
322func TestResetClearsChips(t *testing.T) {

Callers

nothing calls this directly

Calls 8

newChippablePromptFunction · 0.85
makePasteFunction · 0.85
pasteKeyFunction · 0.85
EntryMethod · 0.80
DisplayValueMethod · 0.80
ValueMethod · 0.80
RestoreMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected