oh-my-posh/src/image_test.go
Jan De Dobbeleer b67f625740 fix(bash): escape entire rprompt
resolves #717
2021-05-21 22:12:55 +02:00

41 lines
916 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 := ` oh-my-posh
 main ≡  ~4 -8 ?7 
 `
err := runImageTest(prompt)
assert.NoError(t, err)
}