(t *testing.T)
| 491 | } |
| 492 | |
| 493 | func TestRenderEmojiBordersHaveConsistentWidth(t *testing.T) { |
| 494 | b := NewBox().Padding(2, 1) |
| 495 | b.TopLeft("📦").TopRight("📦").BottomLeft("📦").BottomRight("📦").Horizontal("📦").Vertical("📦") |
| 496 | |
| 497 | out, err := b.Render("Emoji Box", "With emoji borders") |
| 498 | if err != nil { |
| 499 | t.Fatalf("Render with emoji borders returned error: %v", err) |
| 500 | } |
| 501 | |
| 502 | lines := strings.Split(strings.TrimRight(out, "\n"), "\n") |
| 503 | if len(lines) < 3 { |
| 504 | t.Fatalf("expected at least 3 lines in rendered box, got %d", len(lines)) |
| 505 | } |
| 506 | |
| 507 | top := ansi.Strip(lines[0]) |
| 508 | interior := ansi.Strip(lines[1]) |
| 509 | bottom := ansi.Strip(lines[len(lines)-1]) |
| 510 | |
| 511 | topW := runewidth.StringWidth(top) |
| 512 | interiorW := runewidth.StringWidth(interior) |
| 513 | bottomW := runewidth.StringWidth(bottom) |
| 514 | |
| 515 | if topW != interiorW || interiorW != bottomW { |
| 516 | t.Fatalf("expected equal visual widths for emoji box borders, got top=%d interior=%d bottom=%d", topW, interiorW, bottomW) |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | func TestRenderBoxCustomGlyphsWithoutNewBoxMethod(t *testing.T) { |
| 521 | b := new(Box) |
nothing calls this directly
no test coverage detected