diff --git a/render/clone_animation_test.go b/render/clone_animation_test.go index e94d08c..a802a62 100644 --- a/render/clone_animation_test.go +++ b/render/clone_animation_test.go @@ -81,3 +81,18 @@ func TestCloneAnimationBuildFrame(t *testing.T) { } } } + +func TestCloneAnimationDemo(t *testing.T) { + var buf bytes.Buffer + a := NewCloneAnimation(&buf, "repo") + + a.Demo() + + out := buf.String() + if !strings.Contains(out, "100%") { + t.Fatalf("expected demo output to reach 100%%, got %q", out) + } + if !strings.HasSuffix(out, "\n") { + t.Fatalf("expected demo output to end with newline, got %q", out) + } +} diff --git a/render/skyline_test.go b/render/skyline_test.go index c194a48..1db7f81 100644 --- a/render/skyline_test.go +++ b/render/skyline_test.go @@ -2,7 +2,9 @@ package render import ( "bytes" + "io" "math/rand/v2" + "os" "path/filepath" "regexp" "strings" @@ -418,3 +420,39 @@ func TestSkylineMinMax(t *testing.T) { }) } } + +func TestSkylineAnimatePathCallsRenderAnimatedForStdout(t *testing.T) { + project := scanner.Project{ + Root: t.TempDir(), + Name: "Demo", + Files: []scanner.FileInfo{ + {Path: "main.go", Ext: ".go", Size: 100}, + }, + } + + origStdout := os.Stdout + r, w, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + os.Stdout = w + t.Cleanup(func() { + os.Stdout = origStdout + }) + + done := make(chan string, 1) + go func() { + data, _ := io.ReadAll(r) + done <- string(data) + }() + + Skyline(w, project, true) + + if err := w.Close(); err != nil { + t.Fatal(err) + } + out := <-done + if !strings.Contains(out, "Demo") { + t.Fatalf("expected skyline output to include project name, got:\n%s", out) + } +}