MCPcopy
hub / github.com/cli/cli / Test_GhEditor_Prompt_editorAppend

Function Test_GhEditor_Prompt_editorAppend

pkg/surveyext/editor_test.go:88–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func 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
119func Test_GhEditor_Prompt_editorTruncate(t *testing.T) {
120 pty := newTerminal(t)

Callers

nothing calls this directly

Calls 10

PromptMethod · 0.95
newTerminalFunction · 0.85
normalizeANSIFunction · 0.85
defaultPromptConfigFunction · 0.85
StdioMethod · 0.80
WaitForOutputMethod · 0.80
EqualMethod · 0.80
ResetOutputMethod · 0.80
SendKeyMethod · 0.80
OutputMethod · 0.65

Tested by

no test coverage detected