summaryrefslogtreecommitdiff
path: root/test/acceptance/acceptance_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/acceptance/acceptance_test.rb')
-rw-r--r--test/acceptance/acceptance_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/acceptance/acceptance_test.rb b/test/acceptance/acceptance_test.rb
index 13af803..cbc6d45 100644
--- a/test/acceptance/acceptance_test.rb
+++ b/test/acceptance/acceptance_test.rb
@@ -447,6 +447,29 @@ class FzyTest < Minitest::Test
TTY
end
+ def test_field
+ @tty = interactive_fzy(input: %w[1/foo 2/bar], args: "-d/ -f2 -F1")
+ @tty.assert_matches(">\nfoo\nbar")
+
+ @tty.send_keys("foo\r")
+ @tty.assert_matches "1" # the first field
+ end
+
+ def test_field_input_only
+ @tty = interactive_fzy(input: %w[1:foo 2:bar], args: "-f2")
+ @tty.assert_matches ">\nfoo\nbar"
+
+ @tty.send_keys("bar\r")
+ @tty.assert_matches "2:bar" # the whole line
+
+ end
+
+ def test_field_ignored_line
+ # not enough fields for -f or -F
+ @tty = interactive_fzy(input: %w[1:foo:x 2:baz 3 4:bar:y], args: "-f2 -F3")
+ @tty.assert_matches ">\nfoo\nbar"
+ end
+
def test_show_info
@tty = interactive_fzy(input: %w[foo bar baz], args: "-i")
@tty.assert_matches ">\n[3/3]\nfoo\nbar\nbaz"
@@ -469,6 +492,9 @@ Usage: fzy [OPTION]...
-0, --read-null Read input delimited by ASCII NUL characters
-j, --workers NUM Use NUM workers for searching. (default is # of CPUs)
-i, --show-info Show selection info line
+ -d, --delimiter=DELIM Use DELIM to split the line to fields (default ':')
+ -f, --field=NUM Use field NUM for searching (default is the whole line)
+ -F, --output-field=NUM Use field NUM for output (default is the whole line)
-h, --help Display this help and exit
-v, --version Output version information and exit
TTY