MCPcopy
hub / github.com/derailed/k9s / TestPromptColor

Function TestPromptColor

internal/ui/prompt_test.go:104–141  ·  view source on GitHub ↗

Tests that, when active, the prompt has the appropriate color

(t *testing.T)

Source from the content-addressed store, hash-verified

102
103// Tests that, when active, the prompt has the appropriate color
104func TestPromptColor(t *testing.T) {
105 styles := config.NewStyles()
106 app := ui.App{}
107
108 // Make sure to have different values to be sure that the prompt color actually changes depending on its type
109 assert.NotEqual(t,
110 styles.Prompt().Border.DefaultColor.Color(),
111 styles.Prompt().Border.CommandColor.Color(),
112 )
113
114 testCases := []struct {
115 kind model.BufferKind
116 expectedColor tcell.Color
117 }{
118 // Command prompt case
119 {
120 kind: model.CommandBuffer,
121 expectedColor: styles.Prompt().Border.CommandColor.Color(),
122 },
123 // Any other prompt type case
124 {
125 // Simulate a different type of prompt since no particular constant exists
126 kind: model.CommandBuffer + 1,
127 expectedColor: styles.Prompt().Border.DefaultColor.Color(),
128 },
129 }
130
131 for _, testCase := range testCases {
132 m := model.NewFishBuff(':', testCase.kind)
133 prompt := ui.NewPrompt(&app, true, styles)
134
135 prompt.SetModel(m)
136 m.AddListener(prompt)
137
138 m.SetActive(true)
139 assert.Equal(t, testCase.expectedColor, prompt.GetBorderColor())
140 }
141}
142
143// Tests that, when a change of style occurs, the prompt will have the appropriate color when active
144func TestPromptStyleChanged(t *testing.T) {

Callers

nothing calls this directly

Calls 8

PromptMethod · 0.95
SetModelMethod · 0.95
NewStylesFunction · 0.92
NewFishBuffFunction · 0.92
NewPromptFunction · 0.92
ColorMethod · 0.80
AddListenerMethod · 0.65
SetActiveMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…