spec/unit/multi_select_spec.rb in tty-prompt-0.4.0 vs spec/unit/multi_select_spec.rb in tty-prompt-0.5.0
- old
+ new
@@ -81,11 +81,11 @@
menu.choice :wine, 3
menu.choices whisky: 4, bourbon: 5
end
expect(value).to eq([{score: 1}])
expect(prompt.output.string).to eq([
- "\e[?25lSelect drinks? \e[90m(Use arrow or number (0-9) keys, press Space to select and Enter to finish)\e[0m\n",
+ "\e[?25lSelect drinks? \e[90m(Use arrow or number (1-5) keys, press Space to select and Enter to finish)\e[0m\n",
"‣ ⬡ 1) vodka\n",
" ⬡ 2) beer\n",
" ⬡ 3) wine\n",
" ⬡ 4) whisky\n",
" ⬡ 5) bourbon",
@@ -114,11 +114,11 @@
menu.choice :whisky, {score: 40}
menu.choice :bourbon, {score: 50}
end
expect(value).to match_array([{score: 20}, {score: 50}])
expect(prompt.output.string).to eq([
- "\e[?25lSelect drinks? beer, bourbon\n",
+ "\e[?25lSelect drinks? beer, bourbon \e[90m(Use arrow keys, press Space to select and Enter to finish)\e[0m\n",
" ⬡ vodka\n",
" \e[32m⬢\e[0m beer\n",
" ⬡ wine\n",
" ⬡ whisky\n",
"‣ \e[32m⬢\e[0m bourbon",
@@ -170,8 +170,45 @@
" ⬡ wine\n",
" ⬡ whisky\n",
" ⬡ bourbon",
"\e[1000D\e[K\e[1A" * 5, "\e[1000D\e[K",
"[?] Select drinks? \n\e[?25h"
+ ].join)
+ end
+
+ it "changes selected item color & marker" do
+ prompt = TTY::TestPrompt.new
+ choices = %w(vodka beer wine whisky bourbon)
+ prompt.input << "\r"
+ prompt.input.rewind
+ options = {default: [1], active_color: :blue, marker: '>'}
+ expect(prompt.multi_select("Select drinks?", choices, options)). to eq(['vodka'])
+ expect(prompt.output.string).to eq([
+ "\e[?25lSelect drinks? vodka \e[90m(Use arrow keys, press Space to select and Enter to finish)\e[0m\n",
+ "> \e[34m⬢\e[0m vodka\n",
+ " ⬡ beer\n",
+ " ⬡ wine\n",
+ " ⬡ whisky\n",
+ " ⬡ bourbon",
+ "\e[1000D\e[K\e[1A" * 5, "\e[1000D\e[K",
+ "Select drinks? \e[34mvodka\e[0m\n\e[?25h"
+ ].join)
+ end
+
+ it "changes help text" do
+ prompt = TTY::TestPrompt.new
+ choices = %w(vodka beer wine whisky bourbon)
+ prompt.input << "\r"
+ prompt.input.rewind
+ expect(prompt.multi_select("Select drinks?", choices, help: '(Bash keyboard)')). to eq([])
+ expect(prompt.output.string).to eq([
+ "\e[?25lSelect drinks? \e[90m(Bash keyboard)\e[0m\n",
+ "‣ ⬡ vodka\n",
+ " ⬡ beer\n",
+ " ⬡ wine\n",
+ " ⬡ whisky\n",
+ " ⬡ bourbon",
+ "\e[1000D\e[K\e[1A" * 5, "\e[1000D\e[K",
+ "Select drinks? \n\e[?25h"
].join)
end
end