oh-my-posh/engine_test.go

32 lines
549 B
Go
Raw Normal View History

2019-03-13 04:14:30 -07:00
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)
}