MCPcopy Index your code
hub / github.com/cli/cli / Test_GhEditor_Prompt_editorTruncate

Function Test_GhEditor_Prompt_editorTruncate

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

Source from the content-addressed store, hash-verified

117}
118
119func 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
151func defaultPromptConfig() *survey.PromptConfig {

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