Skip to content

Commit

Permalink
test(charmbracelet#58): tested --copy flag
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroSuero committed May 19, 2024
1 parent 37dafec commit d4d556c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions freeze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"

"github.com/aymanbagabas/go-udiff"
"golang.design/x/clipboard"
)

const binary = "./test/freeze-test"
Expand Down Expand Up @@ -56,6 +57,31 @@ func TestFreezeOutput(t *testing.T) {
}
}

func TestFreezeCopy(t *testing.T) {
output := "artichoke-test.svg"
defer os.Remove(output)

cmd := exec.Command(binary, "test/input/artichoke.hs", "-o", output, "--copy")
err := cmd.Run()
if err != nil {
t.Fatal(err)
}

_, err = os.Stat(output)
if err != nil {
t.Fatal(err)
}

err = clipboard.Init()
if err != nil {
t.Fatal(err)
}
png := clipboard.Read(clipboard.FmtImage)
if png == nil {
t.Fatal("clipboard is empty")
}
}

func TestFreezeHelp(t *testing.T) {
out := bytes.Buffer{}
cmd := exec.Command(binary)
Expand Down Expand Up @@ -134,6 +160,11 @@ func TestFreezeConfigurations(t *testing.T) {
flags: []string{"--language", "go", "--height", "800", "--width", "750", "--config", "full", "--window=false", "--show-line-numbers"},
output: "bubbletea",
},
{
input: "test/input/bubbletea.model",
flags: []string{"--language", "go", "--height", "800", "--width", "750", "--config", "full", "--window=false", "--show-line-numbers", "--copy"},
output: "bubbletea-copy",
},
// {
// flags: []string{"--execute", "layout", "--height", "800", "--config", "full", "--margin", "50,10"},
// output: "composite-2",
Expand Down

0 comments on commit d4d556c

Please sign in to comment.