Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
Remove extra %f in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ytang committed Oct 12, 2018
1 parent a98fa7f commit 5737ca6
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 74 deletions.
10 changes: 5 additions & 5 deletions test/core/color_overriding.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ function testDynamicColoringOfSegmentsWork() {
local POWERLEVEL9K_DATE_ICON="date-icon"
local POWERLEVEL9K_DATE_BACKGROUND='red'

assertEquals "%K{001} %F{000}date-icon %f%F{000}%D{%d.%m.%y} %k%F{001}%f " "$(build_left_prompt)"
assertEquals "%K{001} %F{000}date-icon %F{000}%D{%d.%m.%y} %k%F{001}%f " "$(build_left_prompt)"
}

function testDynamicColoringOfVisualIdentifiersWork() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(date)
local POWERLEVEL9K_DATE_ICON="date-icon"
local POWERLEVEL9K_DATE_VISUAL_IDENTIFIER_COLOR='green'

assertEquals "%K{007} %F{002}date-icon %f%F{000}%D{%d.%m.%y} %k%F{007}%f " "$(build_left_prompt)"
assertEquals "%K{007} %F{002}date-icon %F{000}%D{%d.%m.%y} %k%F{007}%f " "$(build_left_prompt)"
}

function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() {
Expand All @@ -34,7 +34,7 @@ function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() {
local POWERLEVEL9K_DATE_FOREGROUND='red'
local POWERLEVEL9K_DATE_BACKGROUND='yellow'

assertEquals "%K{003} %F{002}date-icon %f%F{001}%D{%d.%m.%y} %k%F{003}%f " "$(build_left_prompt)"
assertEquals "%K{003} %F{002}date-icon %F{001}%D{%d.%m.%y} %k%F{003}%f " "$(build_left_prompt)"
}

function testColorOverridingOfStatefulSegment() {
Expand All @@ -45,7 +45,7 @@ function testColorOverridingOfStatefulSegment() {
# Provoke state
local SSH_CLIENT="x"

assertEquals "%K{001} %F{002}ssh-icon %f%F{002}%m %k%F{001}%f " "$(build_left_prompt)"
assertEquals "%K{001} %F{002}ssh-icon %F{002}%m %k%F{001}%f " "$(build_left_prompt)"
}

function testColorOverridingOfCustomSegment() {
Expand All @@ -56,7 +56,7 @@ function testColorOverridingOfCustomSegment() {
local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND='red'
local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND='red'

assertEquals "%K{001} %F{002}CW %f%F{001}world %k%F{001}%f " "$(build_left_prompt)"
assertEquals "%K{001} %F{002}CW %F{001}world %k%F{001}%f " "$(build_left_prompt)"
}

source shunit2/shunit2
8 changes: 4 additions & 4 deletions test/core/visual_identifier.spec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function testOverwritingIconsWork() {
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'

assertEquals "%K{007} %F{000}icon-here %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
assertEquals "%K{007} %F{000}icon-here %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
}

function testVisualIdentifierAppearsBeforeSegmentContentOnLeftSegments() {
Expand All @@ -27,7 +27,7 @@ function testVisualIdentifierAppearsBeforeSegmentContentOnLeftSegments() {
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'

assertEquals "%K{007} %F{000}icon-here %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
assertEquals "%K{007} %F{000}icon-here %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
}

function testVisualIdentifierAppearsAfterSegmentContentOnRightSegments() {
Expand All @@ -36,7 +36,7 @@ function testVisualIdentifierAppearsAfterSegmentContentOnRightSegments() {
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'

assertEquals "%F{007}%f%K{007}%F{000} world1%F{000} icon-here%f%E" "$(build_right_prompt)"
assertEquals "%F{007}%f%K{007}%F{000} world1%F{000} icon-here%E" "$(build_right_prompt)"
}

function testVisualIdentifierPrintsNothingIfNotAvailable() {
Expand All @@ -54,7 +54,7 @@ function testVisualIdentifierIsPrintedInNumericalColorCode() {
local POWERLEVEL9K_CUSTOM_WORLD1_ICON="xxx"
local POWERLEVEL9K_CUSTOM_WORLD1_VISUAL_IDENTIFIER_COLOR="purple3"

assertEquals "%K{007} %F{056}xxx %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
assertEquals "%K{007} %F{056}xxx %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
}

source shunit2/shunit2
6 changes: 3 additions & 3 deletions test/segments/anaconda.spec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() {
CONDA_ENV_PATH=/tmp
unset CONDA_PREFIX

assertEquals "%K{004} %F{000}icon-here %f%F{000}(tmp) %k%F{004}%f " "$(build_left_prompt)"
assertEquals "%K{004} %F{000}icon-here %F{000}(tmp) %k%F{004}%f " "$(build_left_prompt)"
}

function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
Expand All @@ -49,7 +49,7 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
unset CONDA_ENV_PATH
local CONDA_PREFIX="test"

assertEquals "%K{004} %F{000}icon-here %f%F{000}(test) %k%F{004}%f " "$(build_left_prompt)"
assertEquals "%K{004} %F{000}icon-here %F{000}(test) %k%F{004}%f " "$(build_left_prompt)"
}

function testAnacondaSegmentWorks() {
Expand All @@ -63,7 +63,7 @@ function testAnacondaSegmentWorks() {
local CONDA_ENV_PATH=/tmp
local CONDA_PREFIX="test"

assertEquals "%K{004} %F{000}icon-here %f%F{000}(tmptest) %k%F{004}%f " "$(build_left_prompt)"
assertEquals "%K{004} %F{000}icon-here %F{000}(tmptest) %k%F{004}%f " "$(build_left_prompt)"
}

source shunit2/shunit2
4 changes: 2 additions & 2 deletions test/segments/aws_eb_env.spec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSet() {
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
cd /tmp/powerlevel9k-test

assertEquals "%K{000} %F{002}🌱 %f%F{002}test %k%F{000}%f " "$(build_left_prompt)"
assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(build_left_prompt)"

rm -fr /tmp/powerlevel9k-test
cd -
Expand All @@ -52,7 +52,7 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSetInParentDirec
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
cd /tmp/powerlevel9k-test/1/12/123/1234/12345

assertEquals "%K{000} %F{002}🌱 %f%F{002}test %k%F{000}%f " "$(build_left_prompt)"
assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(build_left_prompt)"

rm -fr /tmp/powerlevel9k-test
cd -
Expand Down
6 changes: 3 additions & 3 deletions test/segments/background_jobs.spec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {
# Load Powerlevel9k
source powerlevel9k.zsh-theme

assertEquals "%K{000} %F{006}⚙%f %k%F{000}%f " "$(build_left_prompt)"
assertEquals "%K{000} %F{006}⚙ %k%F{000}%f " "$(build_left_prompt)"

unfunction jobs
}
Expand All @@ -52,7 +52,7 @@ function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
# Load Powerlevel9k
source powerlevel9k.zsh-theme

assertEquals "%K{000} %F{006}⚙%f %k%F{000}%f " "$(build_left_prompt)"
assertEquals "%K{000} %F{006}⚙ %k%F{000}%f " "$(build_left_prompt)"

unfunction jobs
}
Expand All @@ -70,7 +70,7 @@ function testBackgroundJobsSegmentWithVerboseMode() {
# Load Powerlevel9k
source powerlevel9k.zsh-theme

assertEquals "%K{000} %F{006}⚙ %f%F{006}3 %k%F{000}%f " "$(build_left_prompt)"
assertEquals "%K{000} %F{006}⚙ %F{006}3 %k%F{000}%f " "$(build_left_prompt)"

unfunction jobs
}
Expand Down
26 changes: 13 additions & 13 deletions test/segments/battery.spec
Original file line number Diff line number Diff line change
Expand Up @@ -69,82 +69,82 @@ function testBatterySegmentIfBatteryIsLowWhileDischargingOnOSX() {
makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 4%; discharging; 0:05 remaining present: true"

assertEquals "%K{000} %F{001}🔋 %f%F{001}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{001}🔋 %F{001}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsLowWhileChargingOnOSX() {
local OS='OSX' # Fake OSX
makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 4%; charging; 0:05 remaining present: true"

assertEquals "%K{000} %F{003}🔋 %f%F{003}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{003}🔋 %F{003}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsAlmostFullWhileDischargingOnOSX() {
local OS='OSX' # Fake OSX
makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 98%; discharging; 3:57 remaining present: true"

assertEquals "%K{000} %F{007}🔋 %f%F{007}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{007}🔋 %F{007}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsAlmostFullWhileChargingOnOSX() {
local OS='OSX' # Fake OSX
makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 98%; charging; 3:57 remaining present: true"

assertEquals "%K{000} %F{003}🔋 %f%F{003}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{003}🔋 %F{003}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsFullOnOSX() {
local OS='OSX' # Fake OSX
makeBatterySay "Now drawing from 'AC Power'
-InternalBattery-0 (id=1234567) 99%; charged; 0:00 remaining present: true"

assertEquals "%K{000} %F{002}🔋 %f%F{002}99%% " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{002}🔋 %F{002}99%% " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsCalculatingOnOSX() {
local OS='OSX' # Fake OSX
makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 99%; discharging; (no estimate) present: true"

assertEquals "%K{000} %F{007}🔋 %f%F{007}99%% (...) " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{007}🔋 %F{007}99%% (...) " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsLowWhileDischargingOnLinux() {
local OS='Linux' # Fake Linux
makeBatterySay "4" "Discharging"

assertEquals "%K{000} %F{001}🔋 %f%F{001}4%% " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{001}🔋 %F{001}4%% " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsLowWhileChargingOnLinux() {
local OS='Linux' # Fake Linux
makeBatterySay "4" "Charging"

assertEquals "%K{000} %F{003}🔋 %f%F{003}4%% " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{003}🔋 %F{003}4%% " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsNormalWhileDischargingOnLinux() {
local OS='Linux' # Fake Linux
makeBatterySay "10" "Discharging"

assertEquals "%K{000} %F{007}🔋 %f%F{007}10%% " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{007}🔋 %F{007}10%% " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsNormalWhileChargingOnLinux() {
local OS='Linux' # Fake Linux
makeBatterySay "10" "Charging"

assertEquals "%K{000} %F{003}🔋 %f%F{003}10%% " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{003}🔋 %F{003}10%% " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsFullOnLinux() {
local OS='Linux' # Fake Linux
makeBatterySay "100" "Full"

assertEquals "%K{000} %F{002}🔋 %f%F{002}100%% " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{002}🔋 %F{002}100%% " "$(prompt_battery left 1 false ${FOLDER})"
}

function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() {
Expand All @@ -155,7 +155,7 @@ function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() {
# For running on Mac, we need to mock date :(
[[ -f /usr/local/bin/gdate ]] && alias date=gdate

assertEquals "%K{000} %F{007}🔋 %f%F{007}50%% (1:38) " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{007}🔋 %F{007}50%% (1:38) " "$(prompt_battery left 1 false ${FOLDER})"

unalias date &>/dev/null
# unaliasing date fails where it was never aliased (e.g. on Linux).
Expand All @@ -171,7 +171,7 @@ function testBatterySegmentIfBatteryIsCalculatingWithAcpiEnabledOnLinux() {
echo "echo 'Batter 0: Discharging, 50%, rate remaining'" > ${FOLDER}/usr/bin/acpi
chmod +x ${FOLDER}/usr/bin/acpi

assertEquals "%K{000} %F{007}🔋 %f%F{007}50%% (...) " "$(prompt_battery left 1 false ${FOLDER})"
assertEquals "%K{000} %F{007}🔋 %F{007}50%% (...) " "$(prompt_battery left 1 false ${FOLDER})"
}

source shunit2/shunit2
4 changes: 2 additions & 2 deletions test/segments/custom.spec
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function testSettingVisualIdentifierForCustomSegment() {
# Load Powerlevel9k
source powerlevel9k.zsh-theme

assertEquals "%K{007} %F{000}hw %f%F{000}world %k%F{007}%f " "$(build_left_prompt)"
assertEquals "%K{007} %F{000}hw %F{000}world %k%F{007}%f " "$(build_left_prompt)"
}

function testSettingVisualIdentifierForegroundColorForCustomSegment() {
Expand All @@ -80,7 +80,7 @@ function testSettingVisualIdentifierForegroundColorForCustomSegment() {
# Load Powerlevel9k
source powerlevel9k.zsh-theme

assertEquals "%K{007} %F{001}hw %f%F{000}world %k%F{007}%f " "$(build_left_prompt)"
assertEquals "%K{007} %F{001}hw %F{000}world %k%F{007}%f " "$(build_left_prompt)"
}

source shunit2/shunit2
10 changes: 5 additions & 5 deletions test/segments/disk_usage.spec
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function testDiskUsageSegmentWhenDiskIsAlmostFull() {
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme

assertEquals "%K{001} %F{007}hdd %f%F{007}97%% %k%F{001}%f " "$(build_left_prompt)"
assertEquals "%K{001} %F{007}hdd %F{007}97%% %k%F{001}%f " "$(build_left_prompt)"

unfunction df
}
Expand All @@ -56,7 +56,7 @@ function testDiskUsageSegmentWhenDiskIsVeryFull() {
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme

assertEquals "%K{003} %F{000}hdd %f%F{000}94%% %k%F{003}%f " "$(build_left_prompt)"
assertEquals "%K{003} %F{000}hdd %F{000}94%% %k%F{003}%f " "$(build_left_prompt)"

unfunction df
}
Expand All @@ -72,7 +72,7 @@ function testDiskUsageSegmentWhenDiskIsQuiteEmpty() {
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme

assertEquals "%K{000} %F{003}hdd %f%F{003}4%% %k%F{000}%f " "$(build_left_prompt)"
assertEquals "%K{000} %F{003}hdd %F{003}4%% %k%F{000}%f " "$(build_left_prompt)"

unfunction df
}
Expand Down Expand Up @@ -105,7 +105,7 @@ function testDiskUsageSegmentWarningLevelCouldBeAdjusted() {
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme

assertEquals "%K{003} %F{000}hdd %f%F{000}11%% %k%F{003}%f " "$(build_left_prompt)"
assertEquals "%K{003} %F{000}hdd %F{000}11%% %k%F{003}%f " "$(build_left_prompt)"

unfunction df
}
Expand All @@ -123,7 +123,7 @@ function testDiskUsageSegmentCriticalLevelCouldBeAdjusted() {
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme

assertEquals "%K{001} %F{007}hdd %f%F{007}11%% %k%F{001}%f " "$(build_left_prompt)"
assertEquals "%K{001} %F{007}hdd %F{007}11%% %k%F{001}%f " "$(build_left_prompt)"

unfunction df
}
Expand Down
12 changes: 6 additions & 6 deletions test/segments/ip.spec
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() {
source powerlevel9k.zsh-theme
local OS='OSX' # Fake OSX

assertEquals "%K{006} %F{000}IP %f%F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"
assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"

unalias ipconfig
unalias networksetup
Expand Down Expand Up @@ -123,7 +123,7 @@ function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() {
source powerlevel9k.zsh-theme
local OS='OSX' # Fake OSX

assertEquals "%K{006} %F{000}IP %f%F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"
assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"

unfunction ipconfig
unalias networksetup
Expand All @@ -139,7 +139,7 @@ function testIpSegmentWorksOnOsxWithInterfaceSpecified() {
source powerlevel9k.zsh-theme
local OS='OSX' # Fake OSX

assertEquals "%K{006} %F{000}IP %f%F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"
assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"

unalias ipconfig
}
Expand Down Expand Up @@ -169,7 +169,7 @@ function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() {
source powerlevel9k.zsh-theme
local OS='Linux' # Fake Linux

assertEquals "%K{006} %F{000}IP %f%F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"
assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"

unfunction ip
}
Expand Down Expand Up @@ -204,7 +204,7 @@ function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() {
source powerlevel9k.zsh-theme
local OS='Linux' # Fake Linux

assertEquals "%K{006} %F{000}IP %f%F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"
assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"

unfunction ip
}
Expand All @@ -223,7 +223,7 @@ inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
source powerlevel9k.zsh-theme
local OS='Linux' # Fake Linux

assertEquals "%K{006} %F{000}IP %f%F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"
assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"

unfunction ip
}
Expand Down
Loading

0 comments on commit 5737ca6

Please sign in to comment.