File: line_test.go

package info (click to toggle)
moor 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 16,112 kB
  • sloc: sh: 174; ansic: 12; xml: 6; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package reader

import (
	"testing"

	"github.com/walles/moor/internal/textstyles"
	"github.com/walles/moor/twin"
	"gotest.tools/v3/assert"
)

func TestHighlightedTokensWithManPageHeading(t *testing.T) {
	// Set a marker style we can recognize and test for
	textstyles.ManPageHeading = twin.StyleDefault.WithForeground(twin.NewColor16(2))

	headingText := "JOHAN"

	manPageHeading := ""
	for _, char := range headingText {
		manPageHeading += string(char) + "\b" + string(char)
	}

	line := NewLine(manPageHeading)
	highlighted := line.HighlightedTokens(twin.StyleDefault, nil, nil, nil)

	assert.Equal(t, len(highlighted.StyledRunes), len(headingText))
	for i, cell := range highlighted.StyledRunes {
		assert.Equal(t, cell.Rune, rune(headingText[i]))
		assert.Equal(t, cell.Style, textstyles.ManPageHeading)
	}
}