Skip to content
Myr

auto-select.fish

This file

Path

test/auto-select.fish

93 lines · 3.1 KiB

Last changed by

test: Add more test coverage for --auto-select plus --search in dmenu mode.Mark Stosbergbefore adoptione96e76c

History of this file

Take it

✨ Add --auto-select opt. When one entry is left, automatically select it.Mark Stosbergbefore adoption5751a65

lines 1–10why, one step back
1#!/usr/bin/fish
23set got45# Given lines of input as $input and a search string as $search,6# run Fuzzel with auto-select enabled and set the returned string in $got7function test_auto_select --argument-names input search8 rm -f out.txt910 echo -e "$input" \

meson: add fish-based test scriptsDaniel Eklöfbefore adoption7550217

line 11why, one step back
11 | $FUZZEL_TEST_BIN --dmenu --auto-select --search "$search" >out.txt &

✨ Add --auto-select opt. When one entry is left, automatically select it.Mark Stosbergbefore adoption5751a65

lines 12–29why, one step back
12 # Wait for fuzzel to auto-select and exit
13 sleep .314 set got (cat out.txt)15end1617# Test that auto-select works when only one match remains18test_auto_select "apple\nbanana\ncherry" app19@test "auto-select should execute when only one match remains" "$got" = "apple"2021# Test that auto-select works with partial matches22test_auto_select "application\napple\nbanana" applic23@test "auto-select should work with partial matches" "$got" = "application"2425# Test that auto-select doesn't trigger with multiple matches26function test_no_auto_select --argument-names input search27 rm -f out.txt2829 echo -e "$input" \

meson: add fish-based test scriptsDaniel Eklöfbefore adoption7550217

line 30why, one step back
30 | $FUZZEL_TEST_BIN --dmenu --auto-select --search "$search" >out.txt &

✨ Add --auto-select opt. When one entry is left, automatically select it.Mark Stosbergbefore adoption5751a65

lines 31–46why, one step back
31 # Wait briefly to see if fuzzel auto-selects (it shouldn't)
32 sleep .133 # Force exit with Escape34 wtype -k Escape35 sleep .136 set got (cat out.txt)37end3839test_no_auto_select "apple\napricot\nbanana" ap40@test "auto-select should not trigger with multiple matches" "$got" = ""4142# Test without auto-select flag (should not auto-select)43function test_normal_mode --argument-names input search44 rm -f out.txt4546 echo -e "$input" \

meson: add fish-based test scriptsDaniel Eklöfbefore adoption7550217

line 47why, one step back
47 | $FUZZEL_TEST_BIN --dmenu --search "$search" >out.txt &

✨ Add --auto-select opt. When one entry is left, automatically select it.Mark Stosbergbefore adoption5751a65

lines 48–57why, one step back
48 # Wait briefly
49 sleep .150 # Force exit with Escape since it won't auto-select51 wtype -k Escape52 sleep .153 set got (cat out.txt)54end5556test_normal_mode unique uniqu57@test "normal mode should not auto-select even with one match" "$got" = ""

test: Add more test coverage for --auto-select plus --search in dmenu mode.Mark Stosbergbefore adoptione96e76c

lines 58–93why, one step back
58
59# Test --auto-select with --search option60function test_auto_select_with_search --argument-names input search61 rm -f out.txt6263 echo -e "$input" \64 | $FUZZEL_TEST_BIN --dmenu --auto-select --search "$search" >out.txt &65 # Wait for fuzzel to auto-select and exit66 sleep .367 set got (cat out.txt)68end6970# Test that auto-select works with --search when only one match remains71test_auto_select_with_search "application\napple\nbanana" "applic"72@test "auto-select with --search should work when only one match remains" "$got" = "application"7374# Test that auto-select works with --search for exact matches75test_auto_select_with_search "calculator\ncalendar\ncamera" "calculator"76@test "auto-select with --search should work for exact matches" "$got" = "calculator"7778# Test that auto-select with --search doesn't trigger with multiple matches79function test_auto_select_with_search_multiple --argument-names input search80 rm -f out.txt8182 echo -e "$input" \83 | $FUZZEL_TEST_BIN --dmenu --auto-select --search "$search" >out.txt &84 # Wait briefly to see if fuzzel auto-selects (it shouldn't)85 sleep .186 # Force exit with Escape87 wtype -k Escape88 sleep .189 set got (cat out.txt)90end9192test_auto_select_with_search_multiple "apple\napricot\nbanana" "ap"93@test "auto-select with --search should not trigger with multiple matches" "$got" = ""