(t *testing.T)
| 86 | } |
| 87 | |
| 88 | func Test_GhEditor_Prompt_editorAppend(t *testing.T) { |
| 89 | pty := newTerminal(t) |
| 90 | |
| 91 | e := &GhEditor{ |
| 92 | BlankAllowed: true, |
| 93 | EditorCommand: "vim", |
| 94 | Editor: &survey.Editor{ |
| 95 | Message: "Body", |
| 96 | FileName: "*.md", |
| 97 | Default: "initial value", |
| 98 | HideDefault: true, |
| 99 | AppendDefault: true, |
| 100 | }, |
| 101 | lookPath: testLookPath, |
| 102 | } |
| 103 | e.WithStdio(pty.Stdio()) |
| 104 | |
| 105 | // wait until the prompt is rendered and send the 'e' key |
| 106 | go func() { |
| 107 | pty.WaitForOutput("Body") |
| 108 | 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 vim, enter to skip] \x1b[0m", normalizeANSI(pty.Output())) |
| 109 | pty.ResetOutput() |
| 110 | assert.NoError(t, pty.SendKey('e')) |
| 111 | }() |
| 112 | |
| 113 | res, err := e.Prompt(defaultPromptConfig()) |
| 114 | assert.NoError(t, err) |
| 115 | assert.Equal(t, "initial value - added by vim", res) |
| 116 | assert.Equal(t, "", normalizeANSI(pty.Output())) |
| 117 | } |
| 118 | |
| 119 | func Test_GhEditor_Prompt_editorTruncate(t *testing.T) { |
| 120 | pty := newTerminal(t) |
nothing calls this directly
no test coverage detected