oh-my-posh/src/image_test.go
2021-11-09 13:26:59 +01:00

41 lines
925 B
Go
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func runImageTest(content string) error {
poshImagePath := "ohmyposh.png"
file, err := ioutil.TempFile("", poshImagePath)
if err != nil {
return err
}
defer os.Remove(file.Name())
ansi := &ansiUtils{}
ansi.init(plain)
image := &ImageRenderer{
ansiString: content,
ansi: ansi,
}
image.init()
err = image.SavePNG(poshImagePath)
return err
}
func TestStringImageFileWithText(t *testing.T) {
err := runImageTest("foobar")
assert.NoError(t, err)
}
func TestStringImageFileWithANSI(t *testing.T) {
prompt := `\uE0B0 oh-my-posh
\uE0B0 main ≡  ~4 -8 ?7 \uE0B0
 `
err := runImageTest(prompt)
assert.NoError(t, err)
}