(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func Test_GhEditor_Prompt_editorTruncate(t *testing.T) { |
| 120 | pty := newTerminal(t) |
| 121 | |
| 122 | e := &GhEditor{ |
| 123 | BlankAllowed: true, |
| 124 | EditorCommand: "nano", |
| 125 | Editor: &survey.Editor{ |
| 126 | Message: "Body", |
| 127 | FileName: "*.md", |
| 128 | Default: "initial value", |
| 129 | HideDefault: true, |
| 130 | AppendDefault: true, |
| 131 | }, |
| 132 | lookPath: testLookPath, |
| 133 | } |
| 134 | e.WithStdio(pty.Stdio()) |
| 135 | |
| 136 | // wait until the prompt is rendered and send the 'e' key |
| 137 | go func() { |
| 138 | pty.WaitForOutput("Body") |
| 139 | assert.Equal(t, "\x1b[0G\x1b[2K\x1b[0;1;92m? \x1b[0m\x1b[0;1;99mBody \x1b[0m\x1b[0;36m[(e) to launch nano, enter to skip] \x1b[0m", normalizeANSI(pty.Output())) |
| 140 | pty.ResetOutput() |
| 141 | assert.NoError(t, pty.SendKey('e')) |
| 142 | }() |
| 143 | |
| 144 | res, err := e.Prompt(defaultPromptConfig()) |
| 145 | assert.NoError(t, err) |
| 146 | assert.Equal(t, "", res) |
| 147 | assert.Equal(t, "", normalizeANSI(pty.Output())) |
| 148 | } |
| 149 | |
| 150 | // survey doesn't expose this |
| 151 | func defaultPromptConfig() *survey.PromptConfig { |
nothing calls this directly
no test coverage detected