MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / TestBranchWarningBranchEdit

Function TestBranchWarningBranchEdit

internal/tui/branch_warning_test.go:158–203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

156}
157
158func TestBranchWarningBranchEdit(t *testing.T) {
159 bw := NewBranchWarning()
160 bw.SetSize(80, 24)
161 bw.SetContext("main", "auth", ".chief/worktrees/auth/")
162 bw.SetDialogContext(DialogProtectedBranch)
163 bw.Reset()
164
165 // Default branch name
166 if bw.GetSuggestedBranch() != "chief/auth" {
167 t.Errorf("expected branch 'chief/auth', got %q", bw.GetSuggestedBranch())
168 }
169
170 // Enter edit mode
171 bw.StartEditMode()
172 if !bw.IsEditMode() {
173 t.Error("expected edit mode to be true")
174 }
175
176 // Delete and add chars
177 bw.DeleteInputChar()
178 bw.DeleteInputChar()
179 bw.DeleteInputChar()
180 bw.DeleteInputChar()
181 bw.AddInputChar('m')
182 bw.AddInputChar('y')
183 bw.AddInputChar('-')
184 bw.AddInputChar('p')
185 bw.AddInputChar('r')
186 bw.AddInputChar('d')
187 if bw.GetSuggestedBranch() != "chief/my-prd" {
188 t.Errorf("expected 'chief/my-prd', got %q", bw.GetSuggestedBranch())
189 }
190
191 // Invalid characters should be rejected
192 bw.AddInputChar(' ')
193 bw.AddInputChar('!')
194 if bw.GetSuggestedBranch() != "chief/my-prd" {
195 t.Errorf("expected 'chief/my-prd' (unchanged), got %q", bw.GetSuggestedBranch())
196 }
197
198 // Cancel edit mode
199 bw.CancelEditMode()
200 if bw.IsEditMode() {
201 t.Error("expected edit mode to be false")
202 }
203}
204
205func TestBranchWarningPathHints(t *testing.T) {
206 bw := NewBranchWarning()

Callers

nothing calls this directly

Calls 11

SetSizeMethod · 0.95
SetContextMethod · 0.95
SetDialogContextMethod · 0.95
ResetMethod · 0.95
GetSuggestedBranchMethod · 0.95
StartEditModeMethod · 0.95
IsEditModeMethod · 0.95
DeleteInputCharMethod · 0.95
AddInputCharMethod · 0.95
CancelEditModeMethod · 0.95
NewBranchWarningFunction · 0.85

Tested by

no test coverage detected