mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-07 13:33:32 +02:00
update for github.com/AlecAivazis/survey => gopkg.in/AlecAivazis/survey.v1 package
This commit is contained in:
+53
@@ -0,0 +1,53 @@
|
||||
package survey
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/AlecAivazis/survey/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// disable color output for all prompts to simplify testing
|
||||
core.DisableColor = true
|
||||
}
|
||||
|
||||
func TestPasswordRender(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
title string
|
||||
prompt Password
|
||||
data PasswordTemplateData
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
"Test Password question output",
|
||||
Password{Message: "Tell me your secret:"},
|
||||
PasswordTemplateData{},
|
||||
"? Tell me your secret: ",
|
||||
},
|
||||
{
|
||||
"Test Password question output with help hidden",
|
||||
Password{Message: "Tell me your secret:", Help: "This is helpful"},
|
||||
PasswordTemplateData{},
|
||||
"? Tell me your secret: [? for help] ",
|
||||
},
|
||||
{
|
||||
"Test Password question output with help shown",
|
||||
Password{Message: "Tell me your secret:", Help: "This is helpful"},
|
||||
PasswordTemplateData{ShowHelp: true},
|
||||
`ⓘ This is helpful
|
||||
? Tell me your secret: `,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test.data.Password = test.prompt
|
||||
actual, err := core.RunTemplate(
|
||||
PasswordQuestionTemplate,
|
||||
&test.data,
|
||||
)
|
||||
assert.Nil(t, err, test.title)
|
||||
assert.Equal(t, test.expected, actual, test.title)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user