diff --git a/terminal/tcell/cell_options_test.go b/terminal/tcell/cell_options_test.go index b3df570..7c747b2 100644 --- a/terminal/tcell/cell_options_test.go +++ b/terminal/tcell/cell_options_test.go @@ -141,6 +141,21 @@ func TestCellOptsToStyle(t *testing.T) { opts: cell.Options{FgColor: cell.ColorWhite, BgColor: cell.ColorBlack}, want: tcell.StyleDefault.Foreground(tcell.Color23).Background(tcell.Color16), }, + { + colorMode: terminalapi.ColorModeNormal, + opts: cell.Options{Bold: true}, + want: tcell.StyleDefault.Bold(true), + }, + { + colorMode: terminalapi.ColorModeNormal, + opts: cell.Options{Italic: true}, + want: tcell.StyleDefault.Italic(true), + }, + { + colorMode: terminalapi.ColorModeNormal, + opts: cell.Options{Underline: true}, + want: tcell.StyleDefault.Underline(true), + }, } for _, tc := range tests { diff --git a/terminal/termbox/cell_options_test.go b/terminal/termbox/cell_options_test.go index f74e9bb..66d9e1d 100644 --- a/terminal/termbox/cell_options_test.go +++ b/terminal/termbox/cell_options_test.go @@ -15,6 +15,7 @@ package termbox import ( + "fmt" "testing" "github.com/mum4k/termdash/cell" @@ -48,3 +49,25 @@ func TestCellColor(t *testing.T) { }) } } + +func TestCellFontModifier(t *testing.T) { + tests := []struct { + opt cell.Options + want tbx.Attribute + }{ + {cell.Options{Bold: true}, tbx.AttrBold}, + {cell.Options{Underline: true}, tbx.AttrUnderline}, + } + + for _, tc := range tests { + t.Run(fmt.Sprintf("%v", tc.opt), func(t *testing.T) { + got, err := cellOptsToFg(&tc.opt) + if err != nil { + t.Errorf("cellOptsToFg(%v) failed: %s", tc.opt, err) + } + if got != tc.want { + t.Errorf("cellOptsToFg(%v) => got %v, want %v", tc.opt, got, tc.want) + } + }) + } +}