(t *testing.T)
| 156 | } |
| 157 | |
| 158 | func 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 | |
| 205 | func TestBranchWarningPathHints(t *testing.T) { |
| 206 | bw := NewBranchWarning() |
nothing calls this directly
no test coverage detected