aboutsummaryrefslogtreecommitdiff
path: root/test/segments/public_ip.spec
diff options
context:
space:
mode:
Diffstat (limited to 'test/segments/public_ip.spec')
-rwxr-xr-xtest/segments/public_ip.spec29
1 files changed, 27 insertions, 2 deletions
diff --git a/test/segments/public_ip.spec b/test/segments/public_ip.spec
index 80dff215..c4b2ae88 100755
--- a/test/segments/public_ip.spec
+++ b/test/segments/public_ip.spec
@@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() {
export TERM="xterm-256color"
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
# Test specific
P9K_HOME=$(pwd)
@@ -44,6 +42,9 @@ function testPublicIpSegmentPrintsNothingByDefaultIfHostIsNotAvailable() {
# uses an alternative host.
alias dig='nodig'
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias dig
@@ -58,6 +59,9 @@ function testPublicIpSegmentPrintsNoticeIfNotConnected() {
# uses an alternative host.
alias dig='nodig'
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{black} %F{white}disconnected %k%F{black}%f " "$(build_left_prompt)"
unalias dig
@@ -72,6 +76,9 @@ function testPublicIpSegmentWorksWithWget() {
echo "wget 1.2.3.4"
}
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{black} %F{white}wget 1.2.3.4 %k%F{black}%f " "$(build_left_prompt)"
unfunction wget
@@ -88,6 +95,9 @@ function testPublicIpSegmentUsesCurlAsFallbackMethodIfWgetIsNotAvailable() {
echo "curl 1.2.3.4"
}
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{black} %F{white}curl 1.2.3.4 %k%F{black}%f " "$(build_left_prompt)"
unfunction curl
@@ -104,6 +114,9 @@ function testPublicIpSegmentUsesDigAsFallbackMethodIfWgetAndCurlAreNotAvailable(
echo "dig 1.2.3.4"
}
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{black} %F{white}dig 1.2.3.4 %k%F{black}%f " "$(build_left_prompt)"
unfunction dig
@@ -118,6 +131,9 @@ function testPublicIpSegmentCachesFile() {
echo "first"
}
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{black} %F{white}first %k%F{black}%f " "$(build_left_prompt)"
dig() {
@@ -138,6 +154,9 @@ function testPublicIpSegmentRefreshesCachesFileAfterTimeout() {
echo "first"
}
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{black} %F{white}first %k%F{black}%f " "$(build_left_prompt)"
sleep 3
@@ -158,6 +177,9 @@ function testPublicIpSegmentRefreshesCachesFileIfEmpty() {
echo "first"
}
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{black} %F{white}first %k%F{black}%f " "$(build_left_prompt)"
# Truncate cache file
@@ -180,6 +202,9 @@ function testPublicIpSegmentWhenGoingOnline() {
local POWERLEVEL9K_PUBLIC_IP_NONE="disconnected"
alias dig="nodig"
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{black} %F{white}disconnected %k%F{black}%f " "$(build_left_prompt)"
unalias dig