summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2018-07-24 17:34:10 +0300
committerDominik Ritter <dritter03@googlemail.com>2018-07-24 17:34:10 +0300
commit99f0eddd62806f99b8116e3f327689bc32529d5d (patch)
tree1486c6cd7d8e75053a42509320202e71e5030d4e
parent4972f0b8eba711f0dafc46cdbb4e191d550da091 (diff)
Add tests for nerdfont-complete icons
-rwxr-xr-xtest/functions/icons.spec117
1 files changed, 117 insertions, 0 deletions
diff --git a/test/functions/icons.spec b/test/functions/icons.spec
index 068062e6..d4ddc805 100755
--- a/test/functions/icons.spec
+++ b/test/functions/icons.spec
@@ -115,6 +115,15 @@ function testAllIconsAreDefinedLikeInDefaultMode() {
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
+ # Switch to "nerdfont-complete" mode
+ POWERLEVEL9K_MODE="nerdfont-complete"
+ source functions/icons.zsh
+ typeset -ah current_icons
+ current_icons=(${(k)icons[@]})
+ for key in ${_ICONS_UNDER_TEST}; do
+ assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
+ done
+
# Switch to "flat" mode
POWERLEVEL9K_MODE="flat"
source functions/icons.zsh
@@ -187,6 +196,15 @@ function testAllIconsAreDefinedLikeInAwesomePatchedMode() {
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
+ # Switch to "nerdfont-complete" mode
+ POWERLEVEL9K_MODE="nerdfont-complete"
+ source functions/icons.zsh
+ typeset -ah current_icons
+ current_icons=(${(k)icons[@]})
+ for key in ${_ICONS_UNDER_TEST}; do
+ assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
+ done
+
# Switch to "flat" mode
POWERLEVEL9K_MODE="flat"
source functions/icons.zsh
@@ -259,6 +277,15 @@ function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() {
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
+ # Switch to "nerdfont-complete" mode
+ POWERLEVEL9K_MODE="nerdfont-complete"
+ source functions/icons.zsh
+ typeset -ah current_icons
+ current_icons=(${(k)icons[@]})
+ for key in ${_ICONS_UNDER_TEST}; do
+ assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
+ done
+
# Switch to "flat" mode
POWERLEVEL9K_MODE="flat"
source functions/icons.zsh
@@ -331,6 +358,96 @@ function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() {
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
+ # Switch to "nerdfont-complete" mode
+ POWERLEVEL9K_MODE="nerdfont-complete"
+ source functions/icons.zsh
+ typeset -ah current_icons
+ current_icons=(${(k)icons[@]})
+ for key in ${_ICONS_UNDER_TEST}; do
+ assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
+ done
+
+ # Switch to "flat" mode
+ POWERLEVEL9K_MODE="flat"
+ source functions/icons.zsh
+ typeset -ah current_icons
+ current_icons=(${(k)icons[@]})
+ for key in ${_ICONS_UNDER_TEST}; do
+ assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
+ done
+
+ # Switch to "compatible" mode
+ POWERLEVEL9K_MODE="compatible"
+ source functions/icons.zsh
+ typeset -ah current_icons
+ current_icons=(${(k)icons[@]})
+ for key in ${_ICONS_UNDER_TEST}; do
+ assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
+ done
+
+ unset current_icons
+ unset _ICONS_UNDER_TEST
+}
+
+# Go through all icons defined in nerdfont-complete mode, and
+# check if all of them are defined in the other modes.
+function testAllIconsAreDefinedLikeInNerdfontCompleteMode() {
+ # Always compare against this mode
+ local _P9K_TEST_MODE="nerdfont-complete"
+ local POWERLEVEL9K_MODE="$_P9K_TEST_MODE"
+ source functions/icons.zsh
+ # _ICONS_UNDER_TEST is an array of just the keys of $icons.
+ # We later check via (r) "subscript" flag that our key
+ # is in the values of our flat array.
+ typeset -ah _ICONS_UNDER_TEST
+ _ICONS_UNDER_TEST=(${(k)icons[@]})
+
+ # Switch to "default" mode
+ POWERLEVEL9K_MODE="default"
+ source functions/icons.zsh
+ typeset -ah current_icons
+ current_icons=(${(k)icons[@]})
+ for key in ${_ICONS_UNDER_TEST}; do
+ # Iterate over all keys found in the _ICONS_UNDER_TEST
+ # array and compare it with the icons array of the
+ # current POWERLEVEL9K_MODE.
+ # Use parameter expansion, to directly check if the
+ # key exists in the flat current array of keys. That
+ # is quite complicated, but there seems no easy way
+ # to check the mere existance of a key in an array.
+ # The usual way would always return the value, so that
+ # would do the wrong thing as we have some (on purpose)
+ # empty values.
+ assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
+ done
+
+ # Switch to "awesome-patched" mode
+ POWERLEVEL9K_MODE="awesome-patched"
+ source functions/icons.zsh
+ typeset -ah current_icons
+ current_icons=(${(k)icons[@]})
+ for key in ${_ICONS_UNDER_TEST}; do
+ assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
+ done
+
+ # Switch to "awesome-fontconfig" mode
+ POWERLEVEL9K_MODE="awesome-fontconfig"
+ source functions/icons.zsh
+ typeset -ah current_icons
+ current_icons=(${(k)icons[@]})
+ for key in ${_ICONS_UNDER_TEST}; do
+ assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
+ done
+
+ # Switch to "nerdfont-fontconfig" mode
+ POWERLEVEL9K_MODE="nerdfont-fontconfig"
+ source functions/icons.zsh
+ typeset -ah current_icons
+ current_icons=(${(k)icons[@]})
+ for key in ${_ICONS_UNDER_TEST}; do
+ assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
+ done
+
# Switch to "flat" mode
POWERLEVEL9K_MODE="flat"
source functions/icons.zsh