oh-my-posh/src/segment_shell_test.go

46 lines
946 B
Go
Raw Normal View History

2020-09-15 04:44:53 -07:00
package main
import (
"oh-my-posh/mock"
"oh-my-posh/properties"
2020-09-15 04:44:53 -07:00
"testing"
"github.com/stretchr/testify/assert"
)
func TestWriteCurrentShell(t *testing.T) {
expected := "zsh"
env := new(mock.MockedEnvironment)
env.On("Shell").Return(expected, nil)
2022-01-26 05:10:18 -08:00
s := &Shell{
2022-01-01 11:08:08 -08:00
env: env,
props: properties.Map{},
2020-09-15 04:44:53 -07:00
}
2022-01-22 10:46:56 -08:00
_ = s.enabled()
assert.Equal(t, expected, renderTemplate(env, s.template(), s))
2020-09-20 10:13:37 -07:00
}
func TestUseMappedShellNames(t *testing.T) {
cases := []struct {
Shell string
Expected string
}{
{Shell: "zsh", Expected: "zsh"},
{Shell: "pwsh", Expected: "PS"},
{Shell: "PWSH", Expected: "PS"},
}
for _, tc := range cases {
env := new(mock.MockedEnvironment)
env.On("Shell").Return(tc.Expected, nil)
2022-01-26 05:10:18 -08:00
s := &Shell{
env: env,
props: properties.Map{
2021-11-26 01:37:33 -08:00
MappedShellNames: map[string]string{"pwsh": "PS"},
},
}
2022-01-22 10:46:56 -08:00
_ = s.enabled()
got := renderTemplate(env, s.template(), s)
assert.Equal(t, tc.Expected, got)
}
}