1package html
2
3import (
4 "testing"
5
6 "github.com/bnema/vev-vt/core"
7 "github.com/stretchr/testify/require"
8)
9
10func TestRendererCanonicalizesEveryStyleField(t *testing.T) {
11 style := core.DefaultStyle()
12 style.Bold = true
13 style.Italic = true
14 style.Inverse = true
15 style.Attrs = core.AttrDim | core.AttrUnderline | core.AttrBlink | core.AttrStrikethrough
16 style.Foreground = 12
17 style.HasBackgroundRGB = true
18 style.BackgroundRGB = core.RGB{R: 1, G: 2, B: 3}
19 style.UnderlineStyle = core.UnderlineCurly
20 style.HasUnderlineColor = true
21 style.UnderlineColor = 200
22
23 frame := core.NewFrame(1, 1)
24 frame.Set(0, 0, core.Cell{Rune: 'X', Style: style})
25 renderer, err := New(Options{})
26 require.NoError(t, err)
27 prepared, err := renderer.Prepare(frame, nil, false, Cursor{})
28 require.NoError(t, err)
29 require.Equal(t, []Style{{
30 Bold: true, Italic: true, Inverse: true, Dim: true, Blink: true,
31 Strikethrough: true, Underline: true, UnderlineStyle: core.UnderlineCurly,
32 Foreground: Color{Kind: ColorIndexed, Index: 12},
33 Background: Color{Kind: ColorRGB, RGB: RGB{R: 1, G: 2, B: 3}},
34 UnderlineColor: Color{Kind: ColorIndexed, Index: 200},
35 }}, prepared.Update().Styles)
36}