Skip to content

Commit 85fb8fd

Browse files
committed
Add test case for --accept-nth with --filter mode
1 parent 0843c67 commit 85fb8fd

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

test/test_filter.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,18 @@ def test_boundary_match
312312
assert_equal expected, result
313313
end
314314
end
315+
316+
def test_accept_nth_with_filter
317+
# Single field selection
318+
assert_equal 'three', `echo 'one two three' | #{FZF} -d' ' --with-nth 1 --accept-nth -1 -f one`.chomp
319+
320+
# Multiple field selection
321+
writelines(['ID001:John:Developer', 'ID002:Jane:Manager', 'ID003:Bob:Designer'])
322+
assert_equal 'ID001', `#{FZF} -d: --with-nth 2 --accept-nth 1 -f John < #{tempname}`.chomp
323+
assert_equal "ID002:Manager", `#{FZF} -d: --with-nth 2 --accept-nth 1,3 -f Jane < #{tempname}`.chomp
324+
325+
# Test with different delimiters
326+
writelines(['emp001 Alice Engineering', 'emp002 Bob Marketing'])
327+
assert_equal 'emp001', `#{FZF} -d' ' --with-nth 2 --accept-nth 1 -f Alice < #{tempname}`.chomp
328+
end
315329
end

0 commit comments

Comments
 (0)