2020-11-27 19:40:24 +01:00
|
|
|
package display
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2020-11-28 04:50:55 +01:00
|
|
|
|
|
|
|
"github.com/cheat/cheat/internal/config"
|
2020-11-27 19:40:24 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// TestFaint asserts that Faint applies faint formatting
|
|
|
|
func TestFaint(t *testing.T) {
|
2020-11-28 04:50:55 +01:00
|
|
|
|
|
|
|
// case: apply colorization
|
|
|
|
conf := config.Config{Colorize: true}
|
2020-11-27 19:40:24 +01:00
|
|
|
want := "\033[2mfoo\033[0m"
|
2020-11-28 04:50:55 +01:00
|
|
|
got := Faint("foo", conf)
|
|
|
|
if want != got {
|
|
|
|
t.Errorf("failed to faint: want: %s, got: %s", want, got)
|
|
|
|
}
|
|
|
|
|
|
|
|
// case: do not apply colorization
|
|
|
|
conf.Colorize = false
|
|
|
|
want = "foo"
|
|
|
|
got = Faint("foo", conf)
|
2020-11-27 19:40:24 +01:00
|
|
|
if want != got {
|
|
|
|
t.Errorf("failed to faint: want: %s, got: %s", want, got)
|
|
|
|
}
|
|
|
|
}
|