Prepare tests for performance optimizations

pull/22/head
Dominik Ritter 7 years ago
parent 99f0eddd62
commit 06de83cc0f

@ -7,14 +7,16 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function testAnacondaSegmentPrintsNothingIfNoAnacondaPathIsSet() { function testAnacondaSegmentPrintsNothingIfNoAnacondaPathIsSet() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda custom_world) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda custom_world)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Unset anacona variables # Unset anacona variables
unset CONDA_ENV_PATH unset CONDA_ENV_PATH
unset CONDA_PREFIX unset CONDA_PREFIX
@ -23,34 +25,45 @@ function testAnacondaSegmentPrintsNothingIfNoAnacondaPathIsSet() {
} }
function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() { function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() {
CONDA_ENV_PATH=/tmp
unset CONDA_PREFIX
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
local POWERLEVEL9K_PYTHON_ICON="icon-here" local POWERLEVEL9K_PYTHON_ICON="icon-here"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
CONDA_ENV_PATH=/tmp
unset CONDA_PREFIX
assertEquals "%K{blue} %F{black%}icon-here %f%F{black}(tmp) %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black%}icon-here %f%F{black}(tmp) %k%F{blue}%f " "$(build_left_prompt)"
} }
function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() { function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
unset CONDA_ENV_PATH
local CONDA_PREFIX="test"
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
local POWERLEVEL9K_PYTHON_ICON="icon-here" local POWERLEVEL9K_PYTHON_ICON="icon-here"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
unset CONDA_ENV_PATH
local CONDA_PREFIX="test"
assertEquals "%K{blue} %F{black%}icon-here %f%F{black}(test) %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black%}icon-here %f%F{black}(test) %k%F{blue}%f " "$(build_left_prompt)"
} }
function testAnacondaSegmentWorks() { function testAnacondaSegmentWorks() {
local CONDA_ENV_PATH=/tmp
local CONDA_PREFIX="test"
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
local POWERLEVEL9K_PYTHON_ICON="icon-here" local POWERLEVEL9K_PYTHON_ICON="icon-here"
assertEquals "%K{blue} %F{black%}icon-here %f%F{black}(tmptest) %k%F{blue}%f " "$(build_left_prompt)" # Load Powerlevel9k
source powerlevel9k.zsh-theme
local CONDA_ENV_PATH=/tmp
local CONDA_PREFIX="test"
assertEquals "%K{blue} %F{black%}icon-here %f%F{black}(tmptest) %k%F{blue}%f " "$(build_left_prompt)"
} }
source shunit2/source/2.1/src/shunit2 source shunit2/source/2.1/src/shunit2

@ -7,24 +7,30 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function testAwsEbEnvSegmentPrintsNothingIfNoElasticBeanstalkEnvironmentIsSet() { function testAwsEbEnvSegmentPrintsNothingIfNoElasticBeanstalkEnvironmentIsSet() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env custom_world) local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env custom_world)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSet() { function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSet() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
mkdir -p /tmp/powerlevel9k-test/.elasticbeanstalk mkdir -p /tmp/powerlevel9k-test/.elasticbeanstalk
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
cd /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
assertEquals "%K{black} %F{green%}🌱 %f%F{green}test %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{green%}🌱 %f%F{green}test %k%F{black}%f " "$(build_left_prompt)"
rm -fr /tmp/powerlevel9k-test rm -fr /tmp/powerlevel9k-test
@ -35,14 +41,17 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSetInParentDirec
# Skip test, because currently we cannot detect # Skip test, because currently we cannot detect
# if the configuration is in a parent directory # if the configuration is in a parent directory
startSkipping # Skip test startSkipping # Skip test
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
mkdir -p /tmp/powerlevel9k-test/.elasticbeanstalk mkdir -p /tmp/powerlevel9k-test/.elasticbeanstalk
mkdir -p /tmp/powerlevel9k-test/1/12/123/1234/12345 mkdir -p /tmp/powerlevel9k-test/1/12/123/1234/12345
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
cd /tmp/powerlevel9k-test/1/12/123/1234/12345 cd /tmp/powerlevel9k-test/1/12/123/1234/12345
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
assertEquals "%K{black} %F{green%}🌱 %f%F{green}test %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{green%}🌱 %f%F{green}test %k%F{black}%f " "$(build_left_prompt)"
rm -fr /tmp/powerlevel9k-test rm -fr /tmp/powerlevel9k-test

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function testBackgroundJobsSegmentPrintsNothingWithoutBackgroundJobs() { function testBackgroundJobsSegmentPrintsNothingWithoutBackgroundJobs() {
@ -17,6 +15,9 @@ function testBackgroundJobsSegmentPrintsNothingWithoutBackgroundJobs() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs custom_world) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs custom_world)
alias jobs="nojobs 2>/dev/null" alias jobs="nojobs 2>/dev/null"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias jobs unalias jobs
@ -30,6 +31,9 @@ function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {
echo '[1] + 30444 suspended nvim xx' echo '[1] + 30444 suspended nvim xx'
} }
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{cyan%}⚙%f %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{cyan%}⚙%f %k%F{black}%f " "$(build_left_prompt)"
unfunction jobs unfunction jobs
@ -45,6 +49,9 @@ function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
echo "[3] + 31206 suspended nvim xx3" echo "[3] + 31206 suspended nvim xx3"
} }
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{cyan%}⚙%f %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{cyan%}⚙%f %k%F{black}%f " "$(build_left_prompt)"
unfunction jobs unfunction jobs
@ -60,6 +67,9 @@ function testBackgroundJobsSegmentWithVerboseMode() {
echo "[3] + 31206 suspended nvim xx3" echo "[3] + 31206 suspended nvim xx3"
} }
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{cyan%}⚙ %f%F{cyan}3 %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{cyan%}⚙ %f%F{cyan}3 %k%F{black}%f " "$(build_left_prompt)"
unfunction jobs unfunction jobs

@ -37,6 +37,7 @@ function tearDown() {
unset PMSET_PATH unset PMSET_PATH
unset BATTERY_PATH unset BATTERY_PATH
unset FOLDER unset FOLDER
unset P9K_HOME
} }
# Mock Battery # Mock Battery

@ -7,14 +7,17 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function testCommandExecutionTimeIsNotShownIfTimeIsBelowThreshold() { function testCommandExecutionTimeIsNotShownIfTimeIsBelowThreshold() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world command_execution_time) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world command_execution_time)
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Override payload
local _P9K_COMMAND_DURATION=2 local _P9K_COMMAND_DURATION=2
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
@ -24,6 +27,11 @@ function testCommandExecutionTimeThresholdCouldBeChanged() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1 local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Override payload
local _P9K_COMMAND_DURATION=2.03 local _P9K_COMMAND_DURATION=2.03
assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}2.03 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}2.03 %k%F{red}%f " "$(build_left_prompt)"
@ -43,6 +51,11 @@ function testCommandExecutionTimePrecisionCouldBeChanged() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
local POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4 local POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Override payload
local _P9K_COMMAND_DURATION=0.0001 local _P9K_COMMAND_DURATION=0.0001
assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}0.0001 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}0.0001 %k%F{red}%f " "$(build_left_prompt)"
@ -52,6 +65,11 @@ function testCommandExecutionTimePrecisionCouldBeSetToZero() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
local POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 local POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Override payload
local _P9K_COMMAND_DURATION=23.5001 local _P9K_COMMAND_DURATION=23.5001
assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}23 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}23 %k%F{red}%f " "$(build_left_prompt)"
@ -60,6 +78,11 @@ function testCommandExecutionTimePrecisionCouldBeSetToZero() {
function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() { function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Override payload
local _P9K_COMMAND_DURATION=180 local _P9K_COMMAND_DURATION=180
assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}03:00 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}03:00 %k%F{red}%f " "$(build_left_prompt)"
@ -68,6 +91,11 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand()
function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() { function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Override payload
local _P9K_COMMAND_DURATION=7200 local _P9K_COMMAND_DURATION=7200
assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}02:00:00 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}02:00:00 %k%F{red}%f " "$(build_left_prompt)"

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Test specific settings # Test specific settings
OLD_DEFAULT_USER=$DEFAULT_USER OLD_DEFAULT_USER=$DEFAULT_USER
@ -26,6 +24,9 @@ function testContextSegmentDoesNotGetRenderedWithDefaultUser() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context custom_world) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context custom_world)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -34,6 +35,9 @@ function testContextSegmentDoesGetRenderedWhenSshConnectionIsOpen() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)"
} }
@ -41,14 +45,20 @@ function testContextSegmentWithForeignUser() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)"
} }
# TODO: How to test root? # TODO: How to test root?
function testContextSegmentWithRootUser() { function testContextSegmentWithRootUser() {
startSkipping # Skip test
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
startSkipping # Skip test
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)"
} }
@ -58,6 +68,9 @@ function testOverridingContextTemplate() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
local POWERLEVEL9K_CONTEXT_TEMPLATE=xx local POWERLEVEL9K_CONTEXT_TEMPLATE=xx
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow}xx %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow}xx %k%F{black}%f " "$(build_left_prompt)"
} }
@ -67,6 +80,9 @@ function testContextSegmentIsShownIfDefaultUserIsSetWhenForced() {
local POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true local POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
local DEFAULT_USER=$(whoami) local DEFAULT_USER=$(whoami)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)"
} }
@ -76,6 +92,9 @@ function testContextSegmentIsShownIfForced() {
local POWERLEVEL9K_ALWAYS_SHOW_USER=true local POWERLEVEL9K_ALWAYS_SHOW_USER=true
local DEFAULT_USER=$(whoami) local DEFAULT_USER=$(whoami)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow}$(whoami) %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow}$(whoami) %k%F{black}%f " "$(build_left_prompt)"
} }

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function testCustomDirectOutputSegment() { function testCustomDirectOutputSegment() {
@ -16,6 +14,9 @@ function testCustomDirectOutputSegment() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local POWERLEVEL9K_CUSTOM_WORLD="echo world" local POWERLEVEL9K_CUSTOM_WORLD="echo world"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -26,6 +27,9 @@ function testCustomClosureSegment() {
echo "world" echo "world"
} }
local POWERLEVEL9K_CUSTOM_WORLD='p9k_hello_world' local POWERLEVEL9K_CUSTOM_WORLD='p9k_hello_world'
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -36,6 +40,9 @@ function testSettingBackgroundForCustomSegment() {
local POWERLEVEL9K_CUSTOM_WORLD="echo world" local POWERLEVEL9K_CUSTOM_WORLD="echo world"
local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND="yellow" local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND="yellow"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{black}world %k%F{yellow}%f " "$(build_left_prompt)" assertEquals "%K{yellow} %F{black}world %k%F{yellow}%f " "$(build_left_prompt)"
} }
@ -45,6 +52,9 @@ function testSettingForegroundForCustomSegment() {
local POWERLEVEL9K_CUSTOM_WORLD="echo world" local POWERLEVEL9K_CUSTOM_WORLD="echo world"
local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND="red" local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND="red"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{red}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{red}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -54,6 +64,9 @@ function testSettingVisualIdentifierForCustomSegment() {
local POWERLEVEL9K_CUSTOM_WORLD="echo world" local POWERLEVEL9K_CUSTOM_WORLD="echo world"
local POWERLEVEL9K_CUSTOM_WORLD_ICON="hw" local POWERLEVEL9K_CUSTOM_WORLD_ICON="hw"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black%}hw %f%F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black%}hw %f%F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -64,6 +77,9 @@ function testSettingVisualIdentifierForegroundColorForCustomSegment() {
local POWERLEVEL9K_CUSTOM_WORLD_ICON="hw" local POWERLEVEL9K_CUSTOM_WORLD_ICON="hw"
local POWERLEVEL9K_CUSTOM_WORLD_VISUAL_IDENTIFIER_COLOR="red" local POWERLEVEL9K_CUSTOM_WORLD_VISUAL_IDENTIFIER_COLOR="red"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{red%}hw %f%F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{red%}hw %f%F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }

@ -17,6 +17,9 @@ function testDetectVirtSegmentPrintsNothingIfSystemdIsNotAvailable() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias systemd-detect-virt="novirt" alias systemd-detect-virt="novirt"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias systemd-detect-virt unalias systemd-detect-virt
@ -27,6 +30,9 @@ function testDetectVirtSegmentIfSystemdReturnsPlainName() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
alias systemd-detect-virt="echo 'xxx'" alias systemd-detect-virt="echo 'xxx'"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow}xxx %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow}xxx %k%F{black}%f " "$(build_left_prompt)"
unalias systemd-detect-virt unalias systemd-detect-virt
@ -40,6 +46,9 @@ function testDetectVirtSegmentIfRootFsIsOnExpectedInode() {
# directory having the inode number "2".. # directory having the inode number "2"..
alias systemd-detect-virt="echo 'none'" alias systemd-detect-virt="echo 'none'"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# The original command in the implementation is "ls -di / | grep -o 2", # The original command in the implementation is "ls -di / | grep -o 2",
# which translates to: Show the inode number of "/" and test if it is "2". # which translates to: Show the inode number of "/" and test if it is "2".
alias ls="echo '2'" alias ls="echo '2'"
@ -58,6 +67,9 @@ function testDetectVirtSegmentIfRootFsIsNotOnExpectedInode() {
# directory having the inode number "2".. # directory having the inode number "2"..
alias systemd-detect-virt="echo 'none'" alias systemd-detect-virt="echo 'none'"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# The original command in the implementation is "ls -di / | grep -o 2", # The original command in the implementation is "ls -di / | grep -o 2",
# which translates to: Show the inode number of "/" and test if it is "2". # which translates to: Show the inode number of "/" and test if it is "2".
alias ls="echo '3'" alias ls="echo '3'"

@ -7,8 +7,12 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme P9K_HOME="${PWD}"
}
function tearDown() {
unset P9K_HOME
} }
function testDirPathAbsoluteWorks() { function testDirPathAbsoluteWorks() {
@ -16,6 +20,9 @@ function testDirPathAbsoluteWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_ABSOLUTE=true local POWERLEVEL9K_DIR_PATH_ABSOLUTE=true
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
cd ~ cd ~
# Unfortunately, we cannot fake Linux or OSX here, because # Unfortunately, we cannot fake Linux or OSX here, because
@ -36,6 +43,9 @@ function testTruncateFoldersWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER mkdir -p $FOLDER
cd $FOLDER cd $FOLDER
@ -52,6 +62,9 @@ function testTruncateFolderWithHomeDirWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
local CURRENT_DIR=$(pwd) local CURRENT_DIR=$(pwd)
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
cd ~ cd ~
local FOLDER="powerlevel9k-test-${RANDOM}" local FOLDER="powerlevel9k-test-${RANDOM}"
mkdir -p $FOLDER mkdir -p $FOLDER
@ -71,6 +84,9 @@ function testTruncateMiddleWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER mkdir -p $FOLDER
cd $FOLDER cd $FOLDER
@ -87,6 +103,9 @@ function testTruncationFromRightWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER mkdir -p $FOLDER
cd $FOLDER cd $FOLDER
@ -103,6 +122,9 @@ function testTruncateToLastWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_last" local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_last"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER mkdir -p $FOLDER
cd $FOLDER cd $FOLDER
@ -119,6 +141,9 @@ function testTruncateToFirstAndLastWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last" local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER mkdir -p $FOLDER
cd $FOLDER cd $FOLDER
@ -135,6 +160,9 @@ function testTruncateAbsoluteWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_absolute" local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_absolute"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER mkdir -p $FOLDER
cd $FOLDER cd $FOLDER
@ -152,6 +180,9 @@ function testTruncationFromRightWithEmptyDelimiter() {
local POWERLEVEL9K_SHORTEN_DELIMITER="" local POWERLEVEL9K_SHORTEN_DELIMITER=""
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER mkdir -p $FOLDER
cd $FOLDER cd $FOLDER
@ -167,6 +198,9 @@ function testTruncateWithFolderMarkerWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local BASEFOLDER=/tmp/powerlevel9k-test local BASEFOLDER=/tmp/powerlevel9k-test
local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567 local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567
mkdir -p $FOLDER mkdir -p $FOLDER
@ -185,6 +219,9 @@ function testTruncateWithFolderMarkerWithChangedFolderMarker() {
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker"
local POWERLEVEL9K_SHORTEN_FOLDER_MARKER='.xxx' local POWERLEVEL9K_SHORTEN_FOLDER_MARKER='.xxx'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local BASEFOLDER=/tmp/powerlevel9k-test local BASEFOLDER=/tmp/powerlevel9k-test
local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567 local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567
mkdir -p $FOLDER mkdir -p $FOLDER
@ -220,6 +257,9 @@ function testTruncateWithPackageNameWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{blue} %F{black}My_Package/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}My_Package/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)"
# Go back # Go back
@ -257,6 +297,9 @@ function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{blue} %F{black}My_Package/as…/qwerqwer %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}My_Package/as…/qwerqwer %k%F{blue}%f " "$(build_left_prompt)"
# Go back # Go back
@ -290,6 +333,9 @@ function testTruncateWithPackageNameIfRepoIsSymlinkedInsideGitDir() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{blue} %F{black}My_Package/.g…/re…/heads %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}My_Package/.g…/re…/heads %k%F{blue}%f " "$(build_left_prompt)"
# Go back # Go back
@ -302,6 +348,9 @@ function testHomeFolderDetectionWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_HOME_ICON='home-icon' local POWERLEVEL9K_HOME_ICON='home-icon'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
cd ~ cd ~
assertEquals "%K{blue} %F{black%}home-icon %f%F{black}~ %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black%}home-icon %f%F{black}~ %k%F{blue}%f " "$(build_left_prompt)"
@ -313,6 +362,9 @@ function testHomeSubfolderDetectionWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_HOME_SUB_ICON='sub-icon' local POWERLEVEL9K_HOME_SUB_ICON='sub-icon'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local FOLDER=~/powerlevel9k-test local FOLDER=~/powerlevel9k-test
mkdir $FOLDER mkdir $FOLDER
cd $FOLDER cd $FOLDER
@ -327,6 +379,9 @@ function testOtherFolderDetectionWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_FOLDER_ICON='folder-icon' local POWERLEVEL9K_FOLDER_ICON='folder-icon'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local FOLDER=/tmp/powerlevel9k-test local FOLDER=/tmp/powerlevel9k-test
mkdir $FOLDER mkdir $FOLDER
cd $FOLDER cd $FOLDER
@ -340,6 +395,10 @@ function testChangingDirPathSeparator() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local FOLDER="/tmp/powerlevel9k-test/1/2" local FOLDER="/tmp/powerlevel9k-test/1/2"
mkdir -p $FOLDER mkdir -p $FOLDER
cd $FOLDER cd $FOLDER
@ -353,25 +412,40 @@ function testChangingDirPathSeparator() {
function testHomeFolderAbbreviation() { function testHomeFolderAbbreviation() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION
local dir=$PWD local dir=$PWD
cd ~/ cd ~/
# default # default
POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)"
# substituted # substituted
POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{blue} %F{black}qQq %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}qQq %k%F{blue}%f " "$(build_left_prompt)"
cd /tmp cd /tmp
# default # default
POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
# substituted # substituted
POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
cd "$dir" cd "$dir"
@ -382,6 +456,10 @@ function testOmittingFirstCharacterWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
local POWERLEVEL9K_FOLDER_ICON='folder-icon' local POWERLEVEL9K_FOLDER_ICON='folder-icon'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
cd /tmp cd /tmp
assertEquals "%K{blue} %F{black%}folder-icon %f%F{black}tmp %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black%}folder-icon %f%F{black}tmp %k%F{blue}%f " "$(build_left_prompt)"
@ -395,6 +473,10 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparator() {
local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
local POWERLEVEL9K_FOLDER_ICON='folder-icon' local POWERLEVEL9K_FOLDER_ICON='folder-icon'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir -p /tmp/powerlevel9k-test/1/2 mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2
@ -418,6 +500,10 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndDefaultTrunc
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir -p /tmp/powerlevel9k-test/1/2 mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2
@ -434,6 +520,10 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndMiddleTrunca
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir -p /tmp/powerlevel9k-test/1/2 mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2
@ -450,6 +540,10 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncat
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir -p /tmp/powerlevel9k-test/1/2 mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2
@ -466,6 +560,10 @@ function testTruncateToUniqueWorks() {
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_to_unique' local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_to_unique'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir -p /tmp/powerlevel9k-test/adam/devl mkdir -p /tmp/powerlevel9k-test/adam/devl
mkdir -p /tmp/powerlevel9k-test/alice/devl mkdir -p /tmp/powerlevel9k-test/alice/devl
mkdir -p /tmp/powerlevel9k-test/alice/docs mkdir -p /tmp/powerlevel9k-test/alice/docs
@ -482,6 +580,10 @@ function testBoldHomeDirWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
cd ~ cd ~
assertEquals "%K{blue} %F{black}%B~%b %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}%B~%b %k%F{blue}%f " "$(build_left_prompt)"
@ -493,6 +595,10 @@ function testBoldHomeSubdirWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir -p ~/powerlevel9k-test mkdir -p ~/powerlevel9k-test
cd ~/powerlevel9k-test cd ~/powerlevel9k-test
@ -506,6 +612,10 @@ function testBoldRootDirWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
cd / cd /
assertEquals "%K{blue} %F{black}%B/%b %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}%B/%b %k%F{blue}%f " "$(build_left_prompt)"
@ -517,6 +627,10 @@ function testBoldRootSubdirWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
cd /tmp cd /tmp
assertEquals "%K{blue} %F{black}/%Btmp%b %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}/%Btmp%b %k%F{blue}%f " "$(build_left_prompt)"
@ -528,6 +642,10 @@ function testBoldRootSubSubdirWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir -p /tmp/powerlevel9k-test mkdir -p /tmp/powerlevel9k-test
cd /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test
@ -541,6 +659,10 @@ function testHighlightHomeWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
cd ~ cd ~
assertEquals "%K{blue} %F{black}%F{red}~ %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}%F{red}~ %k%F{blue}%f " "$(build_left_prompt)"
@ -552,6 +674,10 @@ function testHighlightHomeSubdirWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir -p ~/powerlevel9k-test mkdir -p ~/powerlevel9k-test
cd ~/powerlevel9k-test cd ~/powerlevel9k-test
@ -565,6 +691,10 @@ function testHighlightRootWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
cd / cd /
assertEquals "%K{blue} %F{black}%F{red}/ %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}%F{red}/ %k%F{blue}%f " "$(build_left_prompt)"
@ -576,6 +706,10 @@ function testHighlightRootSubdirWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
cd /tmp cd /tmp
assertEquals "%K{blue} %F{black}/%F{red}tmp %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black}/%F{red}tmp %k%F{blue}%f " "$(build_left_prompt)"
@ -587,6 +721,10 @@ function testHighlightRootSubSubdirWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir /tmp/powerlevel9k-test mkdir /tmp/powerlevel9k-test
cd /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test
@ -600,6 +738,10 @@ function testDirSeparatorColorHomeSubdirWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' local POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir -p ~/powerlevel9k-test mkdir -p ~/powerlevel9k-test
cd ~/powerlevel9k-test cd ~/powerlevel9k-test
@ -613,6 +755,10 @@ function testDirSeparatorColorRootSubSubdirWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' local POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
mkdir -p /tmp/powerlevel9k-test mkdir -p /tmp/powerlevel9k-test
cd /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Test specific # Test specific
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
@ -39,6 +37,9 @@ function testDiskUsageSegmentWhenDiskIsAlmostFull() {
/dev/disk1 487219288 471466944 15496344 97% /" /dev/disk1 487219288 471466944 15496344 97% /"
} }
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{red} %F{white%}hdd %f%F{white}97%% %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{white%}hdd %f%F{white}97%% %k%F{red}%f " "$(build_left_prompt)"
unfunction df unfunction df
@ -52,6 +53,9 @@ function testDiskUsageSegmentWhenDiskIsVeryFull() {
/dev/disk1 487219288 471466944 15496344 94% /" /dev/disk1 487219288 471466944 15496344 94% /"
} }
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{black%}hdd %f%F{black}94%% %k%F{yellow}%f " "$(build_left_prompt)" assertEquals "%K{yellow} %F{black%}hdd %f%F{black}94%% %k%F{yellow}%f " "$(build_left_prompt)"
unfunction df unfunction df
@ -65,6 +69,9 @@ function testDiskUsageSegmentWhenDiskIsQuiteEmpty() {
/dev/disk1 487219288 471466944 15496344 4% /" /dev/disk1 487219288 471466944 15496344 4% /"
} }
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow%}hdd %f%F{yellow}4%% %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow%}hdd %f%F{yellow}4%% %k%F{black}%f " "$(build_left_prompt)"
unfunction df unfunction df
@ -89,11 +96,14 @@ function testDiskUsageSegmentPrintsNothingIfDiskIsQuiteEmptyAndOnlyWarningsShoul
function testDiskUsageSegmentWarningLevelCouldBeAdjusted() { function testDiskUsageSegmentWarningLevelCouldBeAdjusted() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
local POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=10
df() { df() {
echo "Filesystem 1K-blocks Used Available Use% Mounted on echo "Filesystem 1K-blocks Used Available Use% Mounted on
/dev/disk1 487219288 471466944 15496344 11% /" /dev/disk1 487219288 471466944 15496344 11% /"
} }
local POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=10
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{black%}hdd %f%F{black}11%% %k%F{yellow}%f " "$(build_left_prompt)" assertEquals "%K{yellow} %F{black%}hdd %f%F{black}11%% %k%F{yellow}%f " "$(build_left_prompt)"
@ -103,12 +113,15 @@ function testDiskUsageSegmentWarningLevelCouldBeAdjusted() {
function testDiskUsageSegmentCriticalLevelCouldBeAdjusted() { function testDiskUsageSegmentCriticalLevelCouldBeAdjusted() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
local POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=5
local POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=10
df() { df() {
echo "Filesystem 1K-blocks Used Available Use% Mounted on echo "Filesystem 1K-blocks Used Available Use% Mounted on
/dev/disk1 487219288 471466944 15496344 11% /" /dev/disk1 487219288 471466944 15496344 11% /"
} }
local POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=5
local POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=10 # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{red} %F{white%}hdd %f%F{white}11%% %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{white%}hdd %f%F{white}11%% %k%F{red}%f " "$(build_left_prompt)"

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function mockGo() { function mockGo() {
@ -39,6 +37,9 @@ function testGo() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(go_version) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(go_version)
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k" local PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k"
assertEquals "%K{green} %F{grey93%} %f%F{255}go1.5.3 %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{grey93%} %f%F{255}go1.5.3 %k%F{green}%f " "$(build_left_prompt)"
@ -52,6 +53,9 @@ function testGoSegmentPrintsNothingIfEmptyGopath() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias go=mockGoEmptyGopath alias go=mockGoEmptyGopath
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -61,6 +65,9 @@ function testGoSegmentPrintsNothingIfNotInGopath() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias go=mockGo alias go=mockGo
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -70,6 +77,9 @@ function testGoSegmentPrintsNothingIfGoIsNotAvailable() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias go=noGo alias go=noGo
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias go unalias go

@ -7,17 +7,18 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function testIpSegmentPrintsNothingOnOsxIfNotConnected() { function testIpSegmentPrintsNothingOnOsxIfNotConnected() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world)
alias networksetup='echo "not connected"' alias networksetup='echo "not connected"'
local OS="OSX" # Fake OSX
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local OS="OSX" # Fake OSX
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias networksetup unalias networksetup
@ -27,9 +28,12 @@ function testIpSegmentPrintsNothingOnLinuxIfNotConnected() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world)
alias ip='echo "not connected"' alias ip='echo "not connected"'
local OS="Linux" # Fake Linux
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias ip unalias ip
@ -38,7 +42,6 @@ function testIpSegmentPrintsNothingOnLinuxIfNotConnected() {
function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() { function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='OSX' # Fake OSX
alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled. alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled.
(1) Ethernet (1) Ethernet
(Hardware Port: Ethernet, Device: en0) (Hardware Port: Ethernet, Device: en0)
@ -61,6 +64,10 @@ function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() {
alias ipconfig="_(){ echo '1.2.3.4'; };_" alias ipconfig="_(){ echo '1.2.3.4'; };_"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local OS='OSX' # Fake OSX
assertEquals "%K{cyan} %F{black%}IP %f%F{black}1.2.3.4 %k%F{cyan}%f " "$(build_left_prompt)" assertEquals "%K{cyan} %F{black%}IP %f%F{black}1.2.3.4 %k%F{cyan}%f " "$(build_left_prompt)"
unalias ipconfig unalias ipconfig
@ -74,7 +81,6 @@ function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() {
function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() { function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='OSX' # Fake OSX
alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled. alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled.
(1) Ethernet (1) Ethernet
(Hardware Port: Ethernet, Device: en0) (Hardware Port: Ethernet, Device: en0)
@ -113,6 +119,10 @@ function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() {
} }
} }
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local OS='OSX' # Fake OSX
assertEquals "%K{cyan} %F{black%}IP %f%F{black}1.2.3.4 %k%F{cyan}%f " "$(build_left_prompt)" assertEquals "%K{cyan} %F{black%}IP %f%F{black}1.2.3.4 %k%F{cyan}%f " "$(build_left_prompt)"
unfunction ipconfig unfunction ipconfig
@ -122,10 +132,13 @@ function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() {
function testIpSegmentWorksOnOsxWithInterfaceSpecified() { function testIpSegmentWorksOnOsxWithInterfaceSpecified() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='OSX' # Fake OSX
local POWERLEVEL9K_IP_INTERFACE='xxx' local POWERLEVEL9K_IP_INTERFACE='xxx'
alias ipconfig="_(){ echo '1.2.3.4'; };_" alias ipconfig="_(){ echo '1.2.3.4'; };_"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local OS='OSX' # Fake OSX
assertEquals "%K{cyan} %F{black%}IP %f%F{black}1.2.3.4 %k%F{cyan}%f " "$(build_left_prompt)" assertEquals "%K{cyan} %F{black%}IP %f%F{black}1.2.3.4 %k%F{cyan}%f " "$(build_left_prompt)"
unalias ipconfig unalias ipconfig
@ -134,7 +147,6 @@ function testIpSegmentWorksOnOsxWithInterfaceSpecified() {
function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() { function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() {
setopt aliases setopt aliases
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='Linux' # Fake Linux
# That command is harder to test, as it is used at first # That command is harder to test, as it is used at first
# to get all relevant network interfaces and then for # to get all relevant network interfaces and then for
# getting the configuration of that segment.. # getting the configuration of that segment..
@ -151,18 +163,21 @@ function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() {
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
valid_lft forever preferred_lft forever'; valid_lft forever preferred_lft forever';
fi fi
} }
assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)" # Load Powerlevel9k
source powerlevel9k.zsh-theme
local OS='Linux' # Fake Linux
unfunction ip assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)"
unfunction ip
} }
function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() { function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() {
setopt aliases setopt aliases
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='Linux' # Fake Linux
# That command is harder to test, as it is used at first # That command is harder to test, as it is used at first
# to get all relevant network interfaces and then for # to get all relevant network interfaces and then for
# getting the configuration of that segment.. # getting the configuration of that segment..
@ -183,23 +198,30 @@ function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() {
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
valid_lft forever preferred_lft forever'; valid_lft forever preferred_lft forever';
fi fi
} }
assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)" # Load Powerlevel9k
source powerlevel9k.zsh-theme
local OS='Linux' # Fake Linux
unfunction ip assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)"
unfunction ip
} }
function testIpSegmentWorksOnLinuxWithInterfaceSpecified() { function testIpSegmentWorksOnLinuxWithInterfaceSpecified() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='Linux' # Fake Linux
local POWERLEVEL9K_IP_INTERFACE='xxx' local POWERLEVEL9K_IP_INTERFACE='xxx'
ip(){ ip(){
echo '2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 echo '2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
valid_lft forever preferred_lft forever'; valid_lft forever preferred_lft forever';
} }
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local OS='Linux' # Fake Linux
assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)" assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)"

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function mockKubectl() { function mockKubectl() {
@ -70,6 +68,9 @@ function testKubeContext() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
alias kubectl=mockKubectl alias kubectl=mockKubectl
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{magenta} %F{white%}⎈ %f%F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)" assertEquals "%K{magenta} %F{white%}⎈ %f%F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)"
unalias kubectl unalias kubectl
@ -79,6 +80,9 @@ function testKubeContextOtherNamespace() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
alias kubectl=mockKubectlOtherNamespace alias kubectl=mockKubectlOtherNamespace
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{magenta} %F{white%}⎈ %f%F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)" assertEquals "%K{magenta} %F{white%}⎈ %f%F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)"
unalias kubectl unalias kubectl
@ -89,6 +93,9 @@ function testKubeContextPrintsNothingIfKubectlNotAvailable() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias kubectl=noKubectl alias kubectl=noKubectl
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias kubectl unalias kubectl

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function mockLaravelVersion() { function mockLaravelVersion() {
@ -32,6 +30,9 @@ function testLaravelVersionSegment() {
local POWERLEVEL9K_LARAVEL_ICON='x' local POWERLEVEL9K_LARAVEL_ICON='x'
alias php=mockLaravelVersion alias php=mockLaravelVersion
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{001} %F{white%}x %f%F{white}5.4.23 %k%F{maroon}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{white%}x %f%F{white}5.4.23 %k%F{maroon}%f " "$(build_left_prompt)"
unalias php unalias php
@ -44,6 +45,9 @@ function testLaravelVersionSegmentIfArtisanIsNotAvailable() {
local POWERLEVEL9K_LARAVEL_ICON='x' local POWERLEVEL9K_LARAVEL_ICON='x'
alias php=mockNoLaravelVersion alias php=mockNoLaravelVersion
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias php unalias php
@ -56,6 +60,9 @@ function testLaravelVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
local POWERLEVEL9K_LARAVEL_ICON='x' local POWERLEVEL9K_LARAVEL_ICON='x'
alias php=noPhp alias php=noPhp
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias php unalias php

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
### Test specific ### Test specific
@ -38,9 +36,12 @@ function testLoadSegmentWorksOnOsx() {
fi fi
} }
local OS="OSX" # Fake OSX
local POWERLEVEL9K_LOAD_WHICH=1 local POWERLEVEL9K_LOAD_WHICH=1
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="OSX" # Fake OSX
assertEquals "%K{green} %F{black%}L %f%F{black}1.38 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{green} %F{black%}L %f%F{black}1.38 " "$(prompt_load left 1 false ${FOLDER})"
unfunction sysctl unfunction sysctl
@ -57,8 +58,11 @@ function testLoadSegmentWorksOnBsd() {
fi fi
} }
local OS="BSD" # Fake BSD
local POWERLEVEL9K_LOAD_WHICH=1 local POWERLEVEL9K_LOAD_WHICH=1
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="BSD" # Fake BSD
assertEquals "%K{green} %F{black%}L %f%F{black}1.38 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{green} %F{black%}L %f%F{black}1.38 " "$(prompt_load left 1 false ${FOLDER})"
@ -71,9 +75,11 @@ function testLoadSegmentWorksOnLinux() {
echo "1.38 0.01 0.05 1/87 8641" > proc/loadavg echo "1.38 0.01 0.05 1/87 8641" > proc/loadavg
alias nproc="echo 4" alias nproc="echo 4"
local POWERLEVEL9K_LOAD_WHICH=1
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux local OS="Linux" # Fake Linux
local POWERLEVEL9K_LOAD_WHICH=1
assertEquals "%K{green} %F{black%}L %f%F{black}1.38 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{green} %F{black%}L %f%F{black}1.38 " "$(prompt_load left 1 false ${FOLDER})"
@ -89,9 +95,11 @@ function testLoadSegmentNormalState() {
echo "1.00 0.01 0.05 1/87 8641" > proc/loadavg echo "1.00 0.01 0.05 1/87 8641" > proc/loadavg
alias nproc="echo 4" alias nproc="echo 4"
local POWERLEVEL9K_LOAD_WHICH=1
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux local OS="Linux" # Fake Linux
local POWERLEVEL9K_LOAD_WHICH=1
assertEquals "%K{green} %F{black%}L %f%F{black}1.00 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{green} %F{black%}L %f%F{black}1.00 " "$(prompt_load left 1 false ${FOLDER})"
@ -107,9 +115,11 @@ function testLoadSegmentWarningState() {
echo "2.01 0.01 0.05 1/87 8641" > proc/loadavg echo "2.01 0.01 0.05 1/87 8641" > proc/loadavg
alias nproc="echo 4" alias nproc="echo 4"
local POWERLEVEL9K_LOAD_WHICH=1
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux local OS="Linux" # Fake Linux
local POWERLEVEL9K_LOAD_WHICH=1
assertEquals "%K{yellow} %F{black%}L %f%F{black}2.01 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{yellow} %F{black%}L %f%F{black}2.01 " "$(prompt_load left 1 false ${FOLDER})"
@ -125,9 +135,11 @@ function testLoadSegmentCriticalState() {
echo "2.81 0.01 0.05 1/87 8641" > proc/loadavg echo "2.81 0.01 0.05 1/87 8641" > proc/loadavg
alias nproc="echo 4" alias nproc="echo 4"
local POWERLEVEL9K_LOAD_WHICH=1
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux local OS="Linux" # Fake Linux
local POWERLEVEL9K_LOAD_WHICH=1
assertEquals "%K{red} %F{black%}L %f%F{black}2.81 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{red} %F{black%}L %f%F{black}2.81 " "$(prompt_load left 1 false ${FOLDER})"

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function testNodeVersionSegmentPrintsNothingWithoutNode() { function testNodeVersionSegmentPrintsNothingWithoutNode() {
@ -17,9 +15,11 @@ function testNodeVersionSegmentPrintsNothingWithoutNode() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias node="nonode 2>/dev/null" alias node="nonode 2>/dev/null"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_CUSTOM_WORLD
unalias node unalias node
} }
@ -30,6 +30,9 @@ function testNodeVersionSegmentWorks() {
echo "v1.2.3" echo "v1.2.3"
} }
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{green} %F{white%}⬢ %f%F{white}1.2.3 %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{white%}⬢ %f%F{white}1.2.3 %k%F{green}%f " "$(build_left_prompt)"
unfunction node unfunction node

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Test specfic # Test specfic
# unset all possible user specified variables # unset all possible user specified variables
@ -22,6 +20,9 @@ function testNodeenvSegmentPrintsNothingWithoutNode() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias node="nonode 2>/dev/null" alias node="nonode 2>/dev/null"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias node unalias node
@ -35,6 +36,9 @@ function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvIsNotSet() {
echo "v1.2.3" echo "v1.2.3"
} }
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unfunction node unfunction node
@ -50,6 +54,9 @@ function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvDisablePromptIsSet() {
NODE_VIRTUAL_ENV="node-env" NODE_VIRTUAL_ENV="node-env"
NODE_VIRTUAL_ENV_DISABLE_PROMPT=true NODE_VIRTUAL_ENV_DISABLE_PROMPT=true
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unset NODE_VIRTUAL_ENV_DISABLE_PROMPT unset NODE_VIRTUAL_ENV_DISABLE_PROMPT
@ -63,6 +70,9 @@ function testNodeenvSegmentPrintsAtLeastNodeEnvWithoutNode() {
alias node="nonode 2>/dev/null" alias node="nonode 2>/dev/null"
NODE_VIRTUAL_ENV="node-env" NODE_VIRTUAL_ENV="node-env"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{green%}⬢ %f%F{green}[node-env] %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{green%}⬢ %f%F{green}[node-env] %k%F{black}%f " "$(build_left_prompt)"
unset NODE_VIRTUAL_ENV unset NODE_VIRTUAL_ENV
@ -77,6 +87,9 @@ function testNodeenvSegmentWorks() {
} }
NODE_VIRTUAL_ENV="node-env" NODE_VIRTUAL_ENV="node-env"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{green%}⬢ %f%F{green}v1.2.3[node-env] %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{green%}⬢ %f%F{green}v1.2.3[node-env] %k%F{black}%f " "$(build_left_prompt)"
unfunction node unfunction node

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
### Test specific ### Test specific
@ -36,6 +34,9 @@ function testNvmSegmentPrintsNothingIfNvmIsNotAvailable() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -43,6 +44,9 @@ function testNvmSegmentWorksWithoutHavingADefaultAlias() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm)
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
function nvm_version() { function nvm_version() {
[[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v1.4.0' [[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v1.4.0'
} }
@ -55,6 +59,9 @@ function testNvmSegmentPrintsNothingWhenOnDefaultVersion() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
function nvm_version() { function nvm_version() {
[[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v4.6.0' [[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v4.6.0'
} }

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function testPhpVersionSegmentPrintsNothingIfPhpIsNotAvailable() { function testPhpVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
@ -17,6 +15,9 @@ function testPhpVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias php="nophp" alias php="nophp"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias php unalias php
@ -30,6 +31,9 @@ Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
'" '"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{013} %F{255}PHP 5.6.27 %k%F{fuchsia}%f " "$(build_left_prompt)" assertEquals "%K{013} %F{255}PHP 5.6.27 %k%F{fuchsia}%f " "$(build_left_prompt)"
unalias php unalias php

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
# Test specific # Test specific
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
@ -44,6 +42,9 @@ function testPublicIpSegmentPrintsNothingByDefaultIfHostIsNotAvailable() {
# uses an alternative host. # uses an alternative host.
alias dig='nodig' alias dig='nodig'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias dig unalias dig
@ -58,6 +59,9 @@ function testPublicIpSegmentPrintsNoticeIfNotConnected() {
# uses an alternative host. # uses an alternative host.
alias dig='nodig' alias dig='nodig'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{black} %F{white}disconnected %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{white}disconnected %k%F{black}%f " "$(build_left_prompt)"
unalias dig unalias dig
@ -72,6 +76,9 @@ function testPublicIpSegmentWorksWithWget() {
echo "wget 1.2.3.4" 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)" assertEquals "%K{black} %F{white}wget 1.2.3.4 %k%F{black}%f " "$(build_left_prompt)"
unfunction wget unfunction wget
@ -88,6 +95,9 @@ function testPublicIpSegmentUsesCurlAsFallbackMethodIfWgetIsNotAvailable() {
echo "curl 1.2.3.4" 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)" assertEquals "%K{black} %F{white}curl 1.2.3.4 %k%F{black}%f " "$(build_left_prompt)"
unfunction curl unfunction curl
@ -104,6 +114,9 @@ function testPublicIpSegmentUsesDigAsFallbackMethodIfWgetAndCurlAreNotAvailable(
echo "dig 1.2.3.4" 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)" assertEquals "%K{black} %F{white}dig 1.2.3.4 %k%F{black}%f " "$(build_left_prompt)"
unfunction dig unfunction dig
@ -118,6 +131,9 @@ function testPublicIpSegmentCachesFile() {
echo "first" echo "first"
} }
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{black} %F{white}first %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{white}first %k%F{black}%f " "$(build_left_prompt)"
dig() { dig() {
@ -138,6 +154,9 @@ function testPublicIpSegmentRefreshesCachesFileAfterTimeout() {
echo "first" echo "first"
} }
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{black} %F{white}first %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{white}first %k%F{black}%f " "$(build_left_prompt)"
sleep 3 sleep 3
@ -158,6 +177,9 @@ function testPublicIpSegmentRefreshesCachesFileIfEmpty() {
echo "first" echo "first"
} }
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{black} %F{white}first %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{white}first %k%F{black}%f " "$(build_left_prompt)"
# Truncate cache file # Truncate cache file
@ -180,6 +202,9 @@ function testPublicIpSegmentWhenGoingOnline() {
local POWERLEVEL9K_PUBLIC_IP_NONE="disconnected" local POWERLEVEL9K_PUBLIC_IP_NONE="disconnected"
alias dig="nodig" alias dig="nodig"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{black} %F{white}disconnected %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{white}disconnected %k%F{black}%f " "$(build_left_prompt)"
unalias dig unalias dig

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
### Test specific ### Test specific
@ -28,31 +26,40 @@ function tearDown() {
} }
function testRamSegmentWorksOnOsx() { function testRamSegmentWorksOnOsx() {
local OS="OSX" # Fake OSX
alias vm_stat="echo 'Mach Virtual Memory Statistics: (page size of 4096 bytes) alias vm_stat="echo 'Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free: 299687. Pages free: 299687.
Pages active: 1623792. Pages active: 1623792.
Pages inactive: 1313411. Pages inactive: 1313411.
'" '"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="OSX" # Fake OSX
assertEquals "%K{yellow} %F{black%}RAM %f%F{black}6.15G " "$(prompt_ram left 1 false ${FOLDER})" assertEquals "%K{yellow} %F{black%}RAM %f%F{black}6.15G " "$(prompt_ram left 1 false ${FOLDER})"
unalias vm_stat unalias vm_stat
} }
function testRamSegmentWorksOnBsd() { function testRamSegmentWorksOnBsd() {
local OS="BSD" # Fake BSD
mkdir -p var/run mkdir -p var/run
echo "avail memory 5678B 299687 4444G 299" > var/run/dmesg.boot echo "avail memory 5678B 299687 4444G 299" > var/run/dmesg.boot
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="BSD" # Fake BSD
assertEquals "%K{yellow} %F{black%}RAM %f%F{black}0.29M " "$(prompt_ram left 1 false ${FOLDER})" assertEquals "%K{yellow} %F{black%}RAM %f%F{black}0.29M " "$(prompt_ram left 1 false ${FOLDER})"
} }
function testRamSegmentWorksOnLinux() { function testRamSegmentWorksOnLinux() {
local OS="Linux" # Fake Linux
mkdir proc mkdir proc
echo "MemAvailable: 299687" > proc/meminfo echo "MemAvailable: 299687" > proc/meminfo
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux
assertEquals "%K{yellow} %F{black%}RAM %f%F{black}0.29G " "$(prompt_ram left 1 false ${FOLDER})" assertEquals "%K{yellow} %F{black%}RAM %f%F{black}0.29G " "$(prompt_ram left 1 false ${FOLDER})"
} }

@ -14,8 +14,6 @@ function setUp() {
PATH="${RUST_TEST_FOLDER}:${PATH}" PATH="${RUST_TEST_FOLDER}:${PATH}"
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function tearDown() { function tearDown() {
@ -33,6 +31,9 @@ function testRust() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version)
mockRust mockRust
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{208} %F{black%}Rust %f%F{black}0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" assertEquals "%K{208} %F{black%}Rust %f%F{black}0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)"
} }
@ -41,6 +42,9 @@ function testRustPrintsNothingIfRustIsNotAvailable() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version)
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }

@ -7,12 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
}
function mockRust() {
echo 'rustc 0.4.1a-alpha'
} }
function testSshSegmentPrintsNothingIfNoSshConnection() { function testSshSegmentPrintsNothingIfNoSshConnection() {
@ -25,6 +19,9 @@ function testSshSegmentPrintsNothingIfNoSshConnection() {
unset SSH_CLIENT unset SSH_CLIENT
unset SSH_TTY unset SSH_TTY
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -37,6 +34,9 @@ function testSshSegmentWorksIfOnlySshClientIsSet() {
SSH_CLIENT='ssh-client' SSH_CLIENT='ssh-client'
unset SSH_TTY unset SSH_TTY
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow%}ssh-icon%f %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow%}ssh-icon%f %k%F{black}%f " "$(build_left_prompt)"
unset SSH_CLIENT unset SSH_CLIENT
@ -51,6 +51,9 @@ function testSshSegmentWorksIfOnlySshTtyIsSet() {
SSH_TTY='ssh-tty' SSH_TTY='ssh-tty'
unset SSH_CLIENT unset SSH_CLIENT
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow%}ssh-icon%f %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow%}ssh-icon%f %k%F{black}%f " "$(build_left_prompt)"
unset SSH_TTY unset SSH_TTY
@ -65,6 +68,9 @@ function testSshSegmentWorksIfAllNecessaryVariablesAreSet() {
SSH_CLIENT='ssh-client' SSH_CLIENT='ssh-client'
SSH_TTY='ssh-tty' SSH_TTY='ssh-tty'
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{yellow%}ssh-icon%f %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{yellow%}ssh-icon%f %k%F{black}%f " "$(build_left_prompt)"
unset SSH_TTY unset SSH_TTY

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
### Test specific ### Test specific
# Resets if someone has set these in his/hers env # Resets if someone has set these in his/hers env
@ -23,6 +21,9 @@ function testStatusPrintsNothingIfReturnCodeIsZeroAndVerboseIsUnset() {
local POWERLEVEL9K_STATUS_VERBOSE=false local POWERLEVEL9K_STATUS_VERBOSE=false
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -33,6 +34,9 @@ function testStatusWorksAsExpectedIfReturnCodeIsZeroAndVerboseIsSet() {
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
local POWERLEVEL9K_STATUS_HIDE_SIGNAME=true local POWERLEVEL9K_STATUS_HIDE_SIGNAME=true
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{green%}✔%f %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{green%}✔%f %k%F{black}%f " "$(build_left_prompt)"
} }
@ -41,6 +45,9 @@ function testStatusInGeneralErrorCase() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local POWERLEVEL9K_STATUS_VERBOSE=true local POWERLEVEL9K_STATUS_VERBOSE=true
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local RETVAL=1 local RETVAL=1
assertEquals "%K{red} %F{yellow1%}↵ %f%F{yellow1}1 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}↵ %f%F{yellow1}1 %k%F{red}%f " "$(build_left_prompt)"
@ -51,6 +58,9 @@ function testPipestatusInErrorCase() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local POWERLEVEL9K_STATUS_VERBOSE=true local POWERLEVEL9K_STATUS_VERBOSE=true
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=true local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=true
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local -a RETVALS local -a RETVALS
RETVALS=(0 0 1 0) RETVALS=(0 0 1 0)
@ -63,6 +73,9 @@ function testStatusCrossWinsOverVerbose() {
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
local POWERLEVEL9K_STATUS_VERBOSE=true local POWERLEVEL9K_STATUS_VERBOSE=true
local POWERLEVEL9K_STATUS_CROSS=true local POWERLEVEL9K_STATUS_CROSS=true
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local RETVAL=1 local RETVAL=1
assertEquals "%K{black} %F{red%}✘%f %k%F{black}%f " "$(build_left_prompt)" assertEquals "%K{black} %F{red%}✘%f %k%F{black}%f " "$(build_left_prompt)"
@ -74,6 +87,9 @@ function testStatusShowsSignalNameInErrorCase() {
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
local POWERLEVEL9K_STATUS_VERBOSE=true local POWERLEVEL9K_STATUS_VERBOSE=true
local POWERLEVEL9K_STATUS_HIDE_SIGNAME=false local POWERLEVEL9K_STATUS_HIDE_SIGNAME=false
# Load Powerlevel9k
source powerlevel9k.zsh-theme
local RETVAL=132 local RETVAL=132
assertEquals "%K{red} %F{yellow1%}↵ %f%F{yellow1}SIGILL(4) %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}↵ %f%F{yellow1}SIGILL(4) %k%F{red}%f " "$(build_left_prompt)"
@ -84,6 +100,10 @@ function testStatusSegmentIntegrated() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=() POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
local POWERLEVEL9K_STATUS_CROSS=true
# Load Powerlevel9k
source powerlevel9k.zsh-theme
false; powerlevel9k_prepare_prompts false; powerlevel9k_prepare_prompts

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
### Test specific ### Test specific
@ -30,11 +28,14 @@ function tearDown() {
function testSwapSegmentWorksOnOsx() { function testSwapSegmentWorksOnOsx() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap)
local OS="OSX" # Fake OSX
sysctl() { sysctl() {
echo "vm.swapusage: total = 3072,00M used = 1620,50M free = 1451,50M (encrypted)" echo "vm.swapusage: total = 3072,00M used = 1620,50M free = 1451,50M (encrypted)"
} }
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="OSX" # Fake OSX
assertEquals "%K{yellow} %F{black%}SWP %f%F{black}1.58G " "$(prompt_swap left 1 false ${FOLDER})" assertEquals "%K{yellow} %F{black%}SWP %f%F{black}1.58G " "$(prompt_swap left 1 false ${FOLDER})"
unfunction sysctl unfunction sysctl
@ -43,11 +44,14 @@ function testSwapSegmentWorksOnOsx() {
function testSwapSegmentWorksOnLinux() { function testSwapSegmentWorksOnLinux() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap)
local OS="Linux" # Fake Linux
mkdir proc mkdir proc
echo "SwapTotal: 1000000" > proc/meminfo echo "SwapTotal: 1000000" > proc/meminfo
echo "SwapFree: 1000" >> proc/meminfo echo "SwapFree: 1000" >> proc/meminfo
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux
assertEquals "%K{yellow} %F{black%}SWP %f%F{black}0.95G " "$(prompt_swap left 1 false ${FOLDER})" assertEquals "%K{yellow} %F{black%}SWP %f%F{black}0.95G " "$(prompt_swap left 1 false ${FOLDER})"
} }

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
### Test specific ### Test specific
@ -33,6 +31,8 @@ function testSwiftSegmentPrintsNothingIfSwiftIsNotAvailable() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias swift="noswift" alias swift="noswift"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
@ -46,6 +46,9 @@ function testSwiftSegmentWorks() {
echo "Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)\nTarget: x86_64-apple-macosx10.9" echo "Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)\nTarget: x86_64-apple-macosx10.9"
} }
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{magenta} %F{white%}Swift %f%F{white}3.0.1 %k%F{magenta}%f " "$(build_left_prompt)" assertEquals "%K{magenta} %F{white%}Swift %f%F{white}3.0.1 %k%F{magenta}%f " "$(build_left_prompt)"
unfunction swift unfunction swift

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
### Test specific ### Test specific
@ -33,6 +31,9 @@ function testSymfonyVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias php="nophp" alias php="nophp"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unalias php unalias php
@ -46,6 +47,9 @@ function testSymfonyVersionSegmentPrintsNothingIfSymfonyIsNotAvailable() {
# navigate into a folder that does not contain symfony. # navigate into a folder that does not contain symfony.
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -61,6 +65,9 @@ function testSymfonyVersionPrintsNothingIfPhpThrowsAnError() {
Parse error: parse error, expecting `;´ or `{´ in /Users/dr/Privat/vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php on line 97" Parse error: parse error, expecting `;´ or `{´ in /Users/dr/Privat/vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php on line 97"
} }
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unfunction php unfunction php
@ -77,6 +84,9 @@ function testSymfonyVersionSegmentWorks() {
echo "Symfony version 3.1.4 - app/dev/debug" echo "Symfony version 3.1.4 - app/dev/debug"
} }
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{240} %F{black%}SF %f%F{black}3.1.4 %k%F{240}%f " "$(build_left_prompt)" assertEquals "%K{240} %F{black%}SF %f%F{black}3.1.4 %k%F{240}%f " "$(build_left_prompt)"
unfunction php unfunction php
@ -96,6 +106,9 @@ function testSymfonyVersionSegmentWorksInNestedFolder() {
mkdir -p src/P9K/AppBundle mkdir -p src/P9K/AppBundle
cd src/P9K/AppBundle cd src/P9K/AppBundle
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{240} %F{black%}SF %f%F{black}3.1.4 %k%F{240}%f " "$(build_left_prompt)" assertEquals "%K{240} %F{black%}SF %f%F{black}3.1.4 %k%F{240}%f " "$(build_left_prompt)"
unfunction php unfunction php

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
### Test specific ### Test specific
@ -37,6 +35,9 @@ function testTodoSegmentPrintsNothingIfTodoShIsNotInstalled() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(todo custom_world) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(todo custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world' local POWERLEVEL9K_CUSTOM_WORLD='echo world'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
} }
@ -48,6 +49,9 @@ function testTodoSegmentWorksAsExpected() {
echo 'echo "TODO: 34 of 100 tasks shown";' >> ${FOLDER}/bin/todo.sh echo 'echo "TODO: 34 of 100 tasks shown";' >> ${FOLDER}/bin/todo.sh
chmod +x ${FOLDER}/bin/todo.sh chmod +x ${FOLDER}/bin/todo.sh
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{244} %F{black%}☑ %f%F{black}100 %k%F{grey50}%f " "$(build_left_prompt)" assertEquals "%K{244} %F{black%}☑ %f%F{black}100 %k%F{grey50}%f " "$(build_left_prompt)"
} }

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
### Test specific ### Test specific
@ -75,6 +73,9 @@ function testColorOverridingForCleanStateWorks() {
local POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan' local POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
local POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white' local POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{white} %F{cyan} master %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{cyan} master %k%F{white}%f " "$(build_left_prompt)"
} }
@ -88,6 +89,9 @@ function testColorOverridingForModifiedStateWorks() {
git add testfile git add testfile
git commit -m "test" 1>/dev/null git commit -m "test" 1>/dev/null
echo "test" > testfile echo "test" > testfile
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{red} master ● %k%F{yellow}%f " "$(build_left_prompt)" assertEquals "%K{yellow} %F{red} master ● %k%F{yellow}%f " "$(build_left_prompt)"
} }
@ -100,6 +104,9 @@ function testColorOverridingForUntrackedStateWorks() {
touch testfile touch testfile
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{cyan} master ? %k%F{yellow}%f " "$(build_left_prompt)" assertEquals "%K{yellow} %F{cyan} master ? %k%F{yellow}%f " "$(build_left_prompt)"
} }
@ -107,6 +114,9 @@ function testGitIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_GIT_ICON='Git-Icon' local POWERLEVEL9K_VCS_GIT_ICON='Git-Icon'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black%}Git-Icon %f%F{black} master %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black%}Git-Icon %f%F{black} master %k%F{green}%f " "$(build_left_prompt)"
} }
@ -119,6 +129,9 @@ function testGitlabIconWorks() {
# sufficient to show the GitLab-specific icon. # sufficient to show the GitLab-specific icon.
git remote add origin https://gitlab.com/dritter/gitlab-test-project.git git remote add origin https://gitlab.com/dritter/gitlab-test-project.git
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black%}GL-Icon %f%F{black} master %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black%}GL-Icon %f%F{black} master %k%F{green}%f " "$(build_left_prompt)"
} }
@ -131,6 +144,9 @@ function testBitbucketIconWorks() {
# sufficient to show the BitBucket-specific icon. # sufficient to show the BitBucket-specific icon.
git remote add origin https://dritter@bitbucket.org/dritter/dr-test.git git remote add origin https://dritter@bitbucket.org/dritter/dr-test.git
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black%}BB-Icon %f%F{black} master %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black%}BB-Icon %f%F{black} master %k%F{green}%f " "$(build_left_prompt)"
} }
@ -143,6 +159,9 @@ function testGitHubIconWorks() {
# sufficient to show the GitHub-specific icon. # sufficient to show the GitHub-specific icon.
git remote add origin https://github.com/dritter/test.git git remote add origin https://github.com/dritter/test.git
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black%}GH-Icon %f%F{black} master %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black%}GH-Icon %f%F{black} master %k%F{green}%f " "$(build_left_prompt)"
} }
@ -154,6 +173,9 @@ function testUntrackedFilesIconWorks() {
# Create untracked file # Create untracked file
touch "i-am-untracked.txt" touch "i-am-untracked.txt"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)"
} }
@ -169,7 +191,10 @@ function testStagedFilesIconWorks() {
echo "xx" >> i-am-added.txt echo "xx" >> i-am-added.txt
git add i-am-added.txt &>/dev/null git add i-am-added.txt &>/dev/null
assertEquals "%K{yellow} %F{black} master ✚ %k%F{yellow}%f " "$(build_left_prompt)" # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{black} master + %k%F{yellow}%f " "$(build_left_prompt)"
} }
function testUnstagedFilesIconWorks() { function testUnstagedFilesIconWorks() {
@ -183,7 +208,10 @@ function testUnstagedFilesIconWorks() {
git commit -m "Add File" 1>/dev/null git commit -m "Add File" 1>/dev/null
echo "xx" > i-am-modified.txt echo "xx" > i-am-modified.txt
assertEquals "%K{yellow} %F{black} master ● %k%F{yellow}%f " "$(build_left_prompt)" # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{black} master M %k%F{yellow}%f " "$(build_left_prompt)"
} }
function testStashIconWorks() { function testStashIconWorks() {
@ -198,6 +226,9 @@ function testStashIconWorks() {
echo "xx" > i-am-modified.txt echo "xx" > i-am-modified.txt
git stash 1>/dev/null git stash 1>/dev/null
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black} master S1 %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black} master S1 %k%F{green}%f " "$(build_left_prompt)"
} }
@ -211,6 +242,9 @@ function testTagIconWorks() {
git commit -m "Add File" 1>/dev/null git commit -m "Add File" 1>/dev/null
git tag "v0.0.1" git tag "v0.0.1"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black} master Tv0.0.1 %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black} master Tv0.0.1 %k%F{green}%f " "$(build_left_prompt)"
} }
@ -229,6 +263,9 @@ function testTagIconInDetachedHeadState() {
git checkout v0.0.1 &>/dev/null git checkout v0.0.1 &>/dev/null
local hash=$(git rev-list -n 1 --abbrev-commit --abbrev=8 HEAD) local hash=$(git rev-list -n 1 --abbrev-commit --abbrev=8 HEAD)
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black} ${hash} Tv0.0.1 %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black} ${hash} Tv0.0.1 %k%F{green}%f " "$(build_left_prompt)"
} }
@ -249,6 +286,9 @@ function testActionHintWorks() {
git commit -a -m "Provoke conflict" &>/dev/null git commit -a -m "Provoke conflict" &>/dev/null
git pull &>/dev/null git pull &>/dev/null
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{black} master %F{red}| merge%f %k%F{yellow}%f " "$(build_left_prompt)" assertEquals "%K{yellow} %F{black} master %F{red}| merge%f %k%F{yellow}%f " "$(build_left_prompt)"
} }
@ -268,6 +308,9 @@ function testIncomingHintWorks() {
cd ../vcs-test2 cd ../vcs-test2
git fetch &>/dev/null git fetch &>/dev/null
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black} master I1 %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black} master I1 %k%F{green}%f " "$(build_left_prompt)"
} }
@ -287,6 +330,9 @@ function testOutgoingHintWorks() {
echo "xx" >> i-am-modified.txt echo "xx" >> i-am-modified.txt
git commit -a -m "Modified file" &>/dev/null git commit -a -m "Modified file" &>/dev/null
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black} master o1 %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black} master o1 %k%F{green}%f " "$(build_left_prompt)"
} }
@ -301,6 +347,9 @@ function testShorteningCommitHashWorks() {
git commit -m "Add File" 1>/dev/null git commit -m "Add File" 1>/dev/null
local hash=$(git rev-list -n 1 --abbrev-commit --abbrev=3 HEAD) local hash=$(git rev-list -n 1 --abbrev-commit --abbrev=3 HEAD)
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
# This test needs to call powerlevel9k_vcs_init, where # This test needs to call powerlevel9k_vcs_init, where
# the changeset is truncated. # the changeset is truncated.
powerlevel9k_vcs_init powerlevel9k_vcs_init
@ -317,6 +366,9 @@ function testShorteningCommitHashIsNotShownIfShowChangesetIsFalse() {
git add file.txt git add file.txt
git commit -m "Add File" 1>/dev/null git commit -m "Add File" 1>/dev/null
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
# This test needs to call powerlevel9k_vcs_init, where # This test needs to call powerlevel9k_vcs_init, where
# the changeset is truncated. # the changeset is truncated.
powerlevel9k_vcs_init powerlevel9k_vcs_init

@ -7,8 +7,6 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
P9K_HOME=$(pwd) P9K_HOME=$(pwd)
### Test specific ### Test specific
@ -39,6 +37,9 @@ function testColorOverridingForCleanStateWorks() {
local POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan' local POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
local POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white' local POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{white} %F{cyan} default %k%F{white}%f " "$(build_left_prompt)" assertEquals "%K{white} %F{cyan} default %k%F{white}%f " "$(build_left_prompt)"
} }
@ -53,6 +54,9 @@ function testColorOverridingForModifiedStateWorks() {
hg commit -m "test" 1>/dev/null hg commit -m "test" 1>/dev/null
echo "test" > testfile echo "test" > testfile
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{red} default ● %k%F{yellow}%f " "$(build_left_prompt)" assertEquals "%K{yellow} %F{red} default ● %k%F{yellow}%f " "$(build_left_prompt)"
} }
@ -67,6 +71,9 @@ function testAddedFilesIconWorks() {
touch "myfile.txt" touch "myfile.txt"
hg add myfile.txt hg add myfile.txt
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{black} default ● %k%F{yellow}%f " "$(build_left_prompt)" assertEquals "%K{yellow} %F{black} default ● %k%F{yellow}%f " "$(build_left_prompt)"
} }
@ -82,6 +89,9 @@ function testTagIconWorks() {
hg commit -m "Add File" 1>/dev/null hg commit -m "Add File" 1>/dev/null
hg tag "v0.0.1" hg tag "v0.0.1"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black} default Tv0.0.1 %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black} default Tv0.0.1 %k%F{green}%f " "$(build_left_prompt)"
} }
@ -101,6 +111,9 @@ function testTagIconInDetachedHeadState() {
hg checkout v0.0.1 &>/dev/null hg checkout v0.0.1 &>/dev/null
local hash=$(hg id) local hash=$(hg id)
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black} ${hash} Tv0.0.1 %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black} ${hash} Tv0.0.1 %k%F{green}%f " "$(build_left_prompt)"
} }
@ -121,6 +134,9 @@ function testActionHintWorks() {
hg pull 1>/dev/null hg pull 1>/dev/null
hg merge --tool internal:merge >/dev/null 2>&1 hg merge --tool internal:merge >/dev/null 2>&1
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{yellow} %F{black} default %F{red}| merging%f %k%F{yellow}%f " "$(build_left_prompt)" assertEquals "%K{yellow} %F{black} default %F{red}| merging%f %k%F{yellow}%f " "$(build_left_prompt)"
} }
@ -135,6 +151,9 @@ function testShorteningCommitHashWorks() {
hg commit -m "Add File" 1>/dev/null hg commit -m "Add File" 1>/dev/null
local hash=$(hg id | head -c ${POWERLEVEL9K_CHANGESET_HASH_LENGTH}) local hash=$(hg id | head -c ${POWERLEVEL9K_CHANGESET_HASH_LENGTH})
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
# This test needs to call powerlevel9k_vcs_init, where # This test needs to call powerlevel9k_vcs_init, where
# the changeset is truncated. # the changeset is truncated.
powerlevel9k_vcs_init powerlevel9k_vcs_init
@ -152,6 +171,9 @@ function testShorteningCommitHashIsNotShownIfShowChangesetIsFalse() {
hg add file.txt hg add file.txt
hg commit -m "Add File" 1>/dev/null hg commit -m "Add File" 1>/dev/null
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
# This test needs to call powerlevel9k_vcs_init, where # This test needs to call powerlevel9k_vcs_init, where
# the changeset is truncated. # the changeset is truncated.
powerlevel9k_vcs_init powerlevel9k_vcs_init
@ -164,6 +186,9 @@ function testMercurialIconWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_HG_ICON='HG-Icon' local POWERLEVEL9K_VCS_HG_ICON='HG-Icon'
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black%}HG-Icon %f%F{black} default %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black%}HG-Icon %f%F{black} default %k%F{green}%f " "$(build_left_prompt)"
} }
@ -173,6 +198,9 @@ function testBookmarkIconWorks() {
local POWERLEVEL9K_VCS_BOOKMARK_ICON='B' local POWERLEVEL9K_VCS_BOOKMARK_ICON='B'
hg bookmark "initial" hg bookmark "initial"
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{green} %F{black} default Binitial %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{black} default Binitial %k%F{green}%f " "$(build_left_prompt)"
} }

@ -7,31 +7,41 @@ SHUNIT_PARENT=$0
function setUp() { function setUp() {
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
} }
function testViInsertModeWorks() { function testViInsertModeWorks() {
local KEYMAP='viins' local KEYMAP='viins'
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{blue}INSERT " "$(prompt_vi_mode left 1 false)" assertEquals "%K{black} %F{blue}INSERT " "$(prompt_vi_mode left 1 false)"
} }
function testViInsertModeWorksWhenLabeledAsMain() { function testViInsertModeWorksWhenLabeledAsMain() {
local KEYMAP='main' local KEYMAP='main'
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{blue}INSERT " "$(prompt_vi_mode left 1 false)" assertEquals "%K{black} %F{blue}INSERT " "$(prompt_vi_mode left 1 false)"
} }
function testViCommandModeWorks() { function testViCommandModeWorks() {
local KEYMAP='vicmd' local KEYMAP='vicmd'
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{white}NORMAL " "$(prompt_vi_mode left 1 false)" assertEquals "%K{black} %F{white}NORMAL " "$(prompt_vi_mode left 1 false)"
} }
function testViInsertModeStringIsCustomizable() { function testViInsertModeStringIsCustomizable() {
local KEYMAP='viins' local KEYMAP='viins'
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{black} %F{blue}INSERT " "$(prompt_vi_mode left 1 false)" assertEquals "%K{black} %F{blue}INSERT " "$(prompt_vi_mode left 1 false)"
} }

Loading…
Cancel
Save