diff --git a/tests/common.fish b/tests/common.fish index 020782d..f182a71 100644 --- a/tests/common.fish +++ b/tests/common.fish @@ -4,6 +4,7 @@ function setup # Source plugin source functions/__abbr_tips_init.fish + source functions/__abbr_tips_clean.fish source conf.d/abbr_tips.fish source functions/__abbr_tips_bind_newline.fish source functions/__abbr_tips_bind_space.fish diff --git a/tests/test_init.fish b/tests/test_plugin_init.fish similarity index 100% rename from tests/test_init.fish rename to tests/test_plugin_init.fish diff --git a/tests/test_plugin_update.fish b/tests/test_plugin_update.fish new file mode 100644 index 0000000..b0dec2f --- /dev/null +++ b/tests/test_plugin_update.fish @@ -0,0 +1,44 @@ +source (string join "/" (dirname (status --current-filename)) "common.fish") + +# Test that plugin update reset tip keys + +setup + +@test "plugin update __ABBR_TIPS_KEYS length" ( + set len_keys (count $__ABBR_TIPS_KEYS) + set -a __ABBR_TIPS_KEYS __wrong_key + __abbr_tips_update + test (count $__ABBR_TIPS_KEYS) -eq $len_keys +) "$status" = 0 + +setup + +@test "plugin update __ABBR_TIPS_KEYS value" ( + set last_key "$__ABBR_TIPS_KEYS[-1]" + set -a __ABBR_TIPS_KEYS __wrong_key + __abbr_tips_update + test "$__ABBR_TIPS_KEYS[-1]" = "$last_key" +) "$status" = 0 + +setup + +# Test that plugin update reset tip values + +@test "plugin update __ABBR_TIPS_VALUES length" ( + set len_keys (count $__ABBR_TIPS_VALUES) + set -a __ABBR_TIPS_VALUES __wrong_key + __abbr_tips_update + test (count $__ABBR_TIPS_VALUES) -eq $len_keys +) "$status" = 0 + +setup + +@test "plugin update __ABBR_TIPS_VALUES value" ( + set last_key "$__ABBR_TIPS_VALUES[-1]" + set -a __ABBR_TIPS_VALUES __wrong_key + __abbr_tips_update + test "$__ABBR_TIPS_VALUES[-1]" = "$last_key" +) "$status" = 0 + + +teardown