(t *testing.T)
| 224 | } |
| 225 | |
| 226 | func TestRenderTitlePositions(t *testing.T) { |
| 227 | title := "My Title" |
| 228 | content := "Some content" |
| 229 | |
| 230 | cases := []struct { |
| 231 | name string |
| 232 | pos TitlePosition |
| 233 | }{ |
| 234 | {"inside", Inside}, |
| 235 | {"top", Top}, |
| 236 | {"bottom", Bottom}, |
| 237 | } |
| 238 | |
| 239 | for _, tc := range cases { |
| 240 | t.Run(tc.name, func(t *testing.T) { |
| 241 | b := NewBox().Padding(2, 1).Style(Single).TitlePosition(tc.pos) |
| 242 | out, err := b.Render(title, content) |
| 243 | if err != nil { |
| 244 | t.Fatalf("Render returned error for position %v: %v", tc.pos, err) |
| 245 | } |
| 246 | |
| 247 | lines := strings.Split(out, "\n") |
| 248 | if len(lines) < 3 { |
| 249 | t.Fatalf("expected at least 3 lines, got %d", len(lines)) |
| 250 | } |
| 251 | top := lines[0] |
| 252 | bottom := lines[len(lines)-2] |
| 253 | interior := lines[1 : len(lines)-2] |
| 254 | |
| 255 | hasTitleInside := false |
| 256 | for _, l := range interior { |
| 257 | if strings.Contains(l, title) { |
| 258 | hasTitleInside = true |
| 259 | break |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | switch tc.pos { |
| 264 | case Inside: |
| 265 | if !hasTitleInside { |
| 266 | t.Errorf("expected title to appear inside box for Inside position; output: %q", out) |
| 267 | } |
| 268 | case Top: |
| 269 | if !strings.Contains(top, title) { |
| 270 | t.Errorf("expected title to appear in top bar for Top position; top: %q", top) |
| 271 | } |
| 272 | case Bottom: |
| 273 | if !strings.Contains(bottom, title) { |
| 274 | t.Errorf("expected title to appear in bottom bar for Bottom position; bottom: %q", bottom) |
| 275 | } |
| 276 | } |
| 277 | }) |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | func TestRenderInvalidBoxStyle(t *testing.T) { |
| 282 | b := NewBox().Padding(2, 1).Style(BoxStyle("InvalidStyle")) |
nothing calls this directly
no test coverage detected