Tests that, when active, the prompt has the appropriate color
(t *testing.T)
| 102 | |
| 103 | // Tests that, when active, the prompt has the appropriate color |
| 104 | func 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 |
| 144 | func TestPromptStyleChanged(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…