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

Function TestBuildTitledBar_LeftAlignedWithEmojiFill

util_test.go:396–421  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

394}
395
396func TestBuildTitledBar_LeftAlignedWithEmojiFill(t *testing.T) {
397 fill := "📦"
398 hw := runewidth.StringWidth(fill)
399 title := "Box CLI Maker"
400
401 left := fill
402 right := fill
403 leftW := hw
404 rightW := hw
405 lineWidth := hw*20 + leftW + rightW
406
407 bar := buildTitledBar(left, fill, right, leftW, rightW, lineWidth, hw, title)
408 if w := runewidth.StringWidth(ansi.Strip(bar)); w != lineWidth {
409 t.Fatalf("expected bar visual width %d, got %d", lineWidth, w)
410 }
411 plain := ansi.Strip(bar)
412 if !strings.Contains(plain, " "+title+" ") {
413 t.Fatalf("expected bar to contain title with spaces, got %q", plain)
414 }
415 if !strings.HasPrefix(plain, fill+" ") {
416 t.Errorf("expected left corner followed by space then title, got %q", plain)
417 }
418 if !strings.HasSuffix(plain, fill) {
419 t.Errorf("expected bar to end with fill glyph, got %q", plain)
420 }
421}

Callers

nothing calls this directly

Calls 1

buildTitledBarFunction · 0.85

Tested by

no test coverage detected