mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2025-12-11 22:02:32 +01:00
Prepare tests for performance optimizations
This commit is contained in:
parent
99f0eddd62
commit
06de83cc0f
31 changed files with 645 additions and 117 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue