Skip to content

Commit

Permalink
chore(tests): add a few environment-related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm authored and aymanbagabas committed Feb 18, 2025
1 parent 3e49392 commit 9fe82bc
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,36 @@ func TestHexTo256(t *testing.T) {
})
}
}

func TestDetectionByEnvironment(t *testing.T) {
testCases := map[string]struct {
environ []string
expected Profile
}{
"TERM is set to dumb": {
environ: []string{"TERM=dumb"},
expected: NoTTY,
},
"TERM set to xterm": {
environ: []string{"TERM=xterm"},
expected: ANSI,
},
"TERM is set to rio": {
environ: []string{"TERM=rio"},
expected: TrueColor,
},
"TERM set to xterm-256color": {
environ: []string{"TERM=xterm-256color"},
expected: ANSI256,
},
}

for testName, testCase := range testCases {
t.Run(testName, func(t *testing.T) {
profile := Env(testCase.environ)
if profile != testCase.expected {
t.Errorf("Expected profile to be %s, but instead received %s", testCase.expected, profile)
}
})
}
}

0 comments on commit 9fe82bc

Please sign in to comment.