MCPcopy Create free account
hub / github.com/box-cli-maker/box-cli-maker / TestRenderEmojiBordersHaveConsistentWidth

Function TestRenderEmojiBordersHaveConsistentWidth

box_render_test.go:493–518  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

491}
492
493func 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
520func TestRenderBoxCustomGlyphsWithoutNewBoxMethod(t *testing.T) {
521 b := new(Box)

Callers

nothing calls this directly

Calls 9

NewBoxFunction · 0.85
PaddingMethod · 0.80
VerticalMethod · 0.80
HorizontalMethod · 0.80
BottomRightMethod · 0.80
BottomLeftMethod · 0.80
TopRightMethod · 0.80
TopLeftMethod · 0.80
RenderMethod · 0.80

Tested by

no test coverage detected