summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormatrinox <geofflee21@me.com>2016-02-01 22:01:47 -0800
committerAbinoam Praxedes Marques Jr <abinoam@gmail.com>2016-02-19 04:15:08 -0300
commit9b21f34ddcfac7605f585680a134fe626e588445 (patch)
tree836540cb03cb857dcf252a82495da83dd7d9e8c5 /test
parent3f1935e62b1b8e6f45d02895956c7d6085da9820 (diff)
downloadhighline-9b21f34ddcfac7605f585680a134fe626e588445.tar.gz
Add menu#build_item covenience, bringing us one step closer to a cleaner API
Diffstat (limited to 'test')
-rw-r--r--test/test_menu.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/test_menu.rb b/test/test_menu.rb
index 777b977..d944794 100644
--- a/test/test_menu.rb
+++ b/test/test_menu.rb
@@ -113,7 +113,7 @@ class TestMenu < Minitest::Test
"? ", @output.string)
end
- def test_menu_item_index_selects_name
+ def test_menu_add_item_index_selects_name
@input << "1\n"
@input.rewind
@@ -127,7 +127,7 @@ class TestMenu < Minitest::Test
"? ", @output.string)
end
- def test_menu_item_selections_matches_name
+ def test_menu_add_item_selections_matches_name
@input << "Sample2\n"
@input.rewind
@@ -141,6 +141,20 @@ class TestMenu < Minitest::Test
"? ", @output.string)
end
+ def test_menu_build_item
+ @input << "Sample2\n"
+ @input.rewind
+
+ selected = @terminal.choose do |menu|
+ menu.add_item(menu.build_item("Sample1", text: "Sample2"))
+ menu.add_item(menu.build_item("Sample2", text: "Sample1"))
+ end
+ assert_equal(selected, "Sample2")
+ assert_equal("1. Sample2\n" +
+ "2. Sample1\n" +
+ "? ", @output.string)
+ end
+
def test_help
@input << "help\nhelp load\nhelp rules\nhelp missing\n"
@input.rewind