oh-my-posh/src/segment_shell_test.go

46 lines
883 B
Go
Raw Normal View History

2020-09-15 04:44:53 -07:00
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestWriteCurrentShell(t *testing.T) {
expected := "zsh"
env := new(MockedEnvironment)
env.On("getShellName").Return(expected, nil)
2022-01-22 10:46:56 -08:00
env.onTemplate()
2020-09-15 04:44:53 -07:00
s := &shell{
2022-01-01 11:08:08 -08:00
env: env,
props: properties{},
2020-09-15 04:44:53 -07:00
}
2022-01-22 10:46:56 -08:00
_ = s.enabled()
2020-09-20 10:13:37 -07:00
assert.Equal(t, expected, s.string())
}
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(MockedEnvironment)
env.On("getShellName").Return(tc.Expected, nil)
2022-01-22 10:46:56 -08:00
env.onTemplate()
s := &shell{
env: env,
2022-01-01 11:08:08 -08:00
props: properties{
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 := s.string()
assert.Equal(t, tc.Expected, got)
}
}