oh-my-posh/engine_test.go
2020-09-12 08:57:18 +02:00

32 lines
549 B
Go
Executable file

package main
import (
"bytes"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLenWithoutANSI(t *testing.T) {
block := &Block{
Type: Prompt,
Alignment: Right,
Segments: []*Segment{
{
Type: Time,
Style: Plain,
Background: "#B8B80A",
Foreground: "#ffffff",
},
},
}
engine := &engine{
renderer: &ColorWriter{
Buffer: new(bytes.Buffer),
},
}
blockText := engine.renderBlockSegments(block)
strippedLength := engine.lenWithoutANSI(blockText)
assert.Equal(t, 10, strippedLength)
}