From aadfd86c771bd8b02d419c2830e045f2a3d32c5b Mon Sep 17 00:00:00 2001 From: gazorby Date: Mon, 23 Jan 2023 16:25:00 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20add=20tests=20for=20plugin?= =?UTF-8?q?=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/common.fish | 1 + .../{test_init.fish => test_plugin_init.fish} | 0 tests/test_plugin_update.fish | 44 +++++++++++++++++++ 3 files changed, 45 insertions(+) rename tests/{test_init.fish => test_plugin_init.fish} (100%) create mode 100644 tests/test_plugin_update.fish 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