From d4d556c098d83ee7fd6baaf2b9929a4e69e2d62c Mon Sep 17 00:00:00 2001 From: AlejandroSuero Date: Sun, 19 May 2024 17:05:24 +0200 Subject: [PATCH] test(#58): tested `--copy` flag --- freeze_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/freeze_test.go b/freeze_test.go index 5409a9f..dbb8b6a 100644 --- a/freeze_test.go +++ b/freeze_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/aymanbagabas/go-udiff" + "golang.design/x/clipboard" ) const binary = "./test/freeze-test" @@ -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) @@ -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",