oh-my-posh/src/config/responsive_test.go

36 lines
1.1 KiB
Go
Raw Normal View History

2024-07-01 08:01:05 -07:00
package config
import (
"testing"
"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
2022-12-28 08:30:48 -08:00
"github.com/stretchr/testify/assert"
)
func TestShouldHideForWidth(t *testing.T) {
cases := []struct {
Case string
MinWidth int
MaxWidth int
Width int
Error error
Expected bool
}{
{Case: "No settings"},
{Case: "Min cols - hide", MinWidth: 10, Width: 9, Expected: true},
{Case: "Min cols - show", MinWidth: 10, Width: 20, Expected: false},
{Case: "Max cols - hide", MaxWidth: 10, Width: 11, Expected: true},
{Case: "Max cols - show", MaxWidth: 10, Width: 8, Expected: false},
{Case: "Min & Max cols - hide", MinWidth: 10, MaxWidth: 20, Width: 21, Expected: true},
{Case: "Min & Max cols - hide 2", MinWidth: 10, MaxWidth: 20, Width: 8, Expected: true},
{Case: "Min & Max cols - show", MinWidth: 10, MaxWidth: 20, Width: 11, Expected: false},
}
for _, tc := range cases {
env := new(mock.Environment)
env.On("TerminalWidth").Return(tc.Width, tc.Error)
got := shouldHideForWidth(env, tc.MinWidth, tc.MaxWidth)
assert.Equal(t, tc.Expected, got, tc.Case)
}
}