1package client
2
3import (
4 "testing"
5
6 "github.com/stretchr/testify/require"
7)
8
9func TestDetectTrueColor(t *testing.T) {
10 tests := []struct {
11 name string
12 termEnv string
13 colorTerm string
14 want bool
15 }{
16 {name: "COLORTERM truecolor", termEnv: "screen", colorTerm: "truecolor", want: true},
17 {name: "COLORTERM 24bit", termEnv: "screen", colorTerm: "24bit", want: true},
18 {name: "COLORTERM trims and ignores case", termEnv: "screen", colorTerm: " TRUECOLOR ", want: true},
19 {name: "xterm-direct", termEnv: "xterm-direct", colorTerm: "", want: true},
20 {name: "direct suffix", termEnv: "foot-direct", colorTerm: "", want: true},
21 {name: "direct suffix ignores case and space", termEnv: " FOOT-DIRECT ", colorTerm: "", want: true},
22 {name: "xterm 256 only", termEnv: "xterm-256color", colorTerm: "", want: false},
23 {name: "empty", termEnv: "", colorTerm: "", want: false},
24 }
25
26 for _, tt := range tests {
27 t.Run(tt.name, func(t *testing.T) {
28 require.Equal(t, tt.want, DetectTrueColor(tt.termEnv, tt.colorTerm))
29 })
30 }
31}