Skip to content

Commit

Permalink
Remove option_text from test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisa Ugray committed May 31, 2018
1 parent 8ecb497 commit 1360fa1
Showing 1 changed file with 30 additions and 34 deletions.
64 changes: 30 additions & 34 deletions test/cli/ui/prompt_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def test_confirm_sigint

expected_out = strip_heredoc(<<-EOF) + ' '
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. yes', selected: true)}
#{option_text('2. no')}
\e[?25l> 1. yes\e[K
2. no\e[K
\e[?25h\e[\e[C
EOF
assert_result(expected_out, "", :SIGINT)
Expand Down Expand Up @@ -74,8 +74,8 @@ def test_ask_interactive_sigint

expected_out = strip_heredoc(<<-EOF) + ' '
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. a', selected: true)}
#{option_text('2. b')}
\e[?25l> 1. a\e[K
2. b\e[K
\e[?25h\e[\e[C
EOF
assert_result(expected_out, "", :SIGINT)
Expand All @@ -85,8 +85,8 @@ def test_confirm_happy_path
_run('y') { assert Prompt.confirm('q') }
expected_out = strip_heredoc(<<-EOF) + ' '
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. yes', selected: true)}
#{option_text('2. no')}
\e[?25l> 1. yes\e[K
2. no\e[K
\e[\e[C
#{' ' * CLI::UI::Terminal.width}
#{' ' * CLI::UI::Terminal.width}
Expand All @@ -101,8 +101,8 @@ def test_confirm_invalid
_run(%w(r y n)) { Prompt.confirm('q') }
expected_out = strip_heredoc(<<-EOF) + ' '
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. yes', selected: true)}
#{option_text('2. no')}
\e[?25l> 1. yes\e[K
2. no\e[K
\e[\e[C
#{' ' * CLI::UI::Terminal.width}
#{' ' * CLI::UI::Terminal.width}
Expand All @@ -117,8 +117,8 @@ def test_confirm_no_match_internal
_run('x', 'n') { Prompt.confirm('q') }
expected_out = strip_heredoc(<<-EOF) + ' '
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. yes', selected: true)}
#{option_text('2. no')}
\e[?25l> 1. yes\e[K
2. no\e[K
\e[\e[C
#{' ' * CLI::UI::Terminal.width}
#{' ' * CLI::UI::Terminal.width}
Expand Down Expand Up @@ -217,8 +217,8 @@ def test_ask_interactive_with_block
end
expected_out = strip_heredoc(<<-EOF)
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. a', selected: true)}
#{option_text('2. b')}
\e[?25l> 1. a\e[K
2. b\e[K
\e[\e[C
#{' ' * CLI::UI::Terminal.width}
#{' ' * CLI::UI::Terminal.width}
Expand All @@ -235,8 +235,8 @@ def test_ask_interactive_with_number
end
expected_out = strip_heredoc(<<-EOF)
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. a', selected: true)}
#{option_text('2. b')}
\e[?25l> 1. a\e[K
2. b\e[K
\e[\e[C
#{' ' * CLI::UI::Terminal.width}
#{' ' * CLI::UI::Terminal.width}
Expand All @@ -253,11 +253,11 @@ def test_ask_interactive_with_vim_bound_arrows
end
expected_out = strip_heredoc(<<-EOF)
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. a', selected: true)}
#{option_text('2. b')}
\e[?25l> 1. a\e[K
2. b\e[K
\e[\e[C
#{option_text('1. a')}
#{option_text('2. b', selected: true)}
1. a\e[K
> 2. b\e[K
\e[\e[C
#{' ' * CLI::UI::Terminal.width}
#{' ' * CLI::UI::Terminal.width}
Expand All @@ -274,8 +274,8 @@ def test_ask_interactive_select_using_space
end
expected_out = strip_heredoc(<<-EOF)
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. a', selected: true)}
#{option_text('2. b')}
\e[?25l> 1. a\e[K
2. b\e[K
\e[\e[C
#{' ' * CLI::UI::Terminal.width}
#{' ' * CLI::UI::Terminal.width}
Expand All @@ -297,8 +297,8 @@ def test_ask_interactive_escape

expected_out = strip_heredoc(<<-EOF)
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. a', selected: true)}
#{option_text('2. b')}
\e[?25l> 1. a\e[K
2. b\e[K
\e[?25h\e[\e[C
EOF
assert_result(expected_out, nil, :SIGINT)
Expand All @@ -310,8 +310,8 @@ def test_ask_interactive_invalid_input
end
expected_out = strip_heredoc(<<-EOF)
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. a', selected: true)}
#{option_text('2. b')}
\e[?25l> 1. a\e[K
2. b\e[K
\e[\e[C
#{' ' * CLI::UI::Terminal.width}
#{' ' * CLI::UI::Terminal.width}
Expand All @@ -332,14 +332,14 @@ def test_ask_interactive_with_blank_option
blank = ''
expected_out = strip_heredoc(<<-EOF)
? q (choose with ↑ ↓ ⏎)
\e[?25l#{option_text('1. a', selected: true)}
#{option_text("2.#{blank}")}
\e[?25l> 1. a\e[K
2.#{blank}\e[K
\e[\e[C
#{option_text('1. a')}
#{option_text("2.#{blank}", selected: true)}
1. a\e[K
> 2.#{blank}\e[K
\e[\e[C
#{option_text('1. a', selected: true)}
#{option_text("2.#{blank}")}
> 1. a\e[K
2.#{blank}\e[K
\e[\e[C
#{' ' * CLI::UI::Terminal.width}
#{' ' * CLI::UI::Terminal.width}
Expand All @@ -352,10 +352,6 @@ def test_ask_interactive_with_blank_option

private

def option_text(text, selected: false)
"#{selected ? "> " : " "}#{text}#{CLI::UI::ANSI.clear_to_end_of_line}"
end

def _run(*lines)
$stdin = @in_r
start_process { @ret.write(Marshal.dump(yield)) }
Expand Down

0 comments on commit 1360fa1

Please sign in to comment.