mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-14 15:04:03 -08:00
32 lines
738 B
Go
32 lines
738 B
Go
package engine
|
|
|
|
import (
|
|
"oh-my-posh/environment"
|
|
"oh-my-posh/mock"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestConsoleBackgroundColorTemplate(t *testing.T) {
|
|
cases := []struct {
|
|
Case string
|
|
Expected string
|
|
Term string
|
|
}{
|
|
{Case: "Inside vscode", Expected: "#123456", Term: "vscode"},
|
|
{Case: "Outside vscode", Expected: "", Term: "windowsterminal"},
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
env := new(mock.MockedEnvironment)
|
|
env.On("TemplateCache").Return(&environment.TemplateCache{
|
|
Env: map[string]string{
|
|
"TERM_PROGRAM": tc.Term,
|
|
},
|
|
})
|
|
color := GetConsoleBackgroundColor(env, "{{ if eq \"vscode\" .Env.TERM_PROGRAM }}#123456{{end}}")
|
|
assert.Equal(t, tc.Expected, color, tc.Case)
|
|
}
|
|
}
|