mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
32 lines
549 B
Go
Executable file
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)
|
|
}
|