zk/tests/test_get_command.sh

51 lines
1001 B
Bash
Raw Normal View History

2023-12-07 17:58:37 +00:00
#!/bin/bash
setup() {
source ../zk
}
test_get_command_returns_list_for_substring() {
expected="list"
for arg in l li lis list; do
2023-12-08 17:29:26 +00:00
result="$(get_command "$ZKCOMMANDS" "$arg")"
assert_equals "$expected" "$result"
done
}
test_get_command_returns_search_for_substring() {
expected="search"
for arg in s se sea sear searc search; do
result="$(get_command "$ZKCOMMANDS" "$arg")"
assert_equals "$expected" "$result"
done
}
test_get_command_returns_new_for_substring() {
expected="new"
for arg in n ne new; do
result="$(get_command "$ZKCOMMANDS" "$arg")"
2023-12-07 17:58:37 +00:00
assert_equals "$expected" "$result"
done
}
2023-12-08 17:57:00 +00:00
test_get_command_returns_edit_for_substring() {
expected="edit"
for arg in e ed edi edit; do
result="$(get_command "$ZKCOMMANDS" "$arg")"
assert_equals "$expected" "$result"
done
}
test_get_command_does_not_return_match_unless_at_start_of_command_string() {
commands="delete"
expected=""
result="$(get_command "$commands" "l")"
assert_equals "$expected" "$result"
}