TestErrorBoxUsesCentralizedBorder verifies that ErrorBox uses the centralized RoundedBorder
(t *testing.T)
| 375 | |
| 376 | // TestErrorBoxUsesCentralizedBorder verifies that ErrorBox uses the centralized RoundedBorder |
| 377 | func TestErrorBoxUsesCentralizedBorder(t *testing.T) { |
| 378 | // Create a style with the RoundedBorder to compare |
| 379 | testStyle := lipgloss.NewStyle(). |
| 380 | Border(RoundedBorder). |
| 381 | BorderForeground(ColorError). |
| 382 | Padding(1). |
| 383 | Margin(1) |
| 384 | |
| 385 | testText := "Test error message" |
| 386 | errorBoxResult := ErrorBox.Render(testText) |
| 387 | testStyleResult := testStyle.Render(testText) |
| 388 | |
| 389 | // Both should contain the test text |
| 390 | if len(errorBoxResult) == 0 { |
| 391 | t.Error("ErrorBox rendered empty string") |
| 392 | } |
| 393 | if len(testStyleResult) == 0 { |
| 394 | t.Error("testStyle rendered empty string") |
| 395 | } |
| 396 | |
| 397 | // Verify that ErrorBox output contains the rounded border characters |
| 398 | // RoundedBorder uses: ╭ (top-left), ╮ (top-right), ╰ (bottom-left), ╯ (bottom-right) |
| 399 | if !strings.Contains(errorBoxResult, "╭") { |
| 400 | t.Error("ErrorBox missing rounded top-left corner (╭)") |
| 401 | } |
| 402 | if !strings.Contains(errorBoxResult, "╮") { |
| 403 | t.Error("ErrorBox missing rounded top-right corner (╮)") |
| 404 | } |
| 405 | if !strings.Contains(errorBoxResult, "╰") { |
| 406 | t.Error("ErrorBox missing rounded bottom-left corner (╰)") |
| 407 | } |
| 408 | if !strings.Contains(errorBoxResult, "╯") { |
| 409 | t.Error("ErrorBox missing rounded bottom-right corner (╯)") |
| 410 | } |
| 411 | |
| 412 | // Both should produce identical output (same border, same styling) |
| 413 | if errorBoxResult != testStyleResult { |
| 414 | t.Errorf("ErrorBox output differs from expected:\nGot:\n%s\nExpected:\n%s", errorBoxResult, testStyleResult) |
| 415 | } |
| 416 | } |