Update status unit test

This commit is contained in:
Ilan Cosman 2020-07-08 18:37:47 -07:00
parent ec49a86c4d
commit 54b18da465
2 changed files with 26 additions and 3 deletions

View File

@ -1,15 +1,26 @@
function _tide_item_status function _tide_item_status
if string match -q --invert '0' $_tide_last_pipestatus # If there is a failure somewhere in the pipestatus if string match -q --invert '0' $_tide_last_pipestatus # If there is a failure anywhere in the pipestatus
if test "$_tide_last_pipestatus" = '1'
if test "$tide_status_always_display_icon" = 'true'
set -g tide_status_bg_color $tide_status_failure_bg_color
set_color $tide_status_failure_color
printf '%s' "$tide_status_failure_icon 1"
end
return 0
end
if test $_tide_last_status -eq 0 if test $_tide_last_status -eq 0
set -g tide_status_bg_color $tide_status_success_bg_color set -g tide_status_bg_color $tide_status_success_bg_color
set_color $tide_status_success_color set_color $tide_status_success_color
printf '%s' {$tide_status_success_icon}' ' printf '%s' $tide_status_success_icon
else else
set -g tide_status_bg_color $tide_status_failure_bg_color set -g tide_status_bg_color $tide_status_failure_bg_color
set_color $tide_status_failure_color set_color $tide_status_failure_color
printf '%s' {$tide_status_failure_icon}' ' printf '%s' $tide_status_failure_icon
end end
printf '%s' ' '
__fish_pipestatus_with_signal $_tide_last_pipestatus | string replace 'SIG' '' | string join '|' __fish_pipestatus_with_signal $_tide_last_pipestatus | string replace 'SIG' '' | string join '|'
else if test "$tide_status_always_display_icon" = 'true' else if test "$tide_status_always_display_icon" = 'true'
set -g tide_status_bg_color $tide_status_success_bg_color set -g tide_status_bg_color $tide_status_success_bg_color

View File

@ -6,9 +6,21 @@ function _status
_tide_decolor (_tide_item_status) _tide_decolor (_tide_item_status)
end end
set -l saved_tide_status_always_display_icon $tide_status_always_display_icon
set -g tide_status_always_display_icon false
@test 'true' (true; _status) -z @test 'true' (true; _status) -z
@test 'false' (false; _status) -z @test 'false' (false; _status) -z
@test 'true|false' (true|false; _status) = "$tide_status_failure_icon 0|1" @test 'true|false' (true|false; _status) = "$tide_status_failure_icon 0|1"
@test 'true|true' (true|true; _status) -z @test 'true|true' (true|true; _status) -z
@test 'false|true' (false|true; _status) = "$tide_status_success_icon 1|0" @test 'false|true' (false|true; _status) = "$tide_status_success_icon 1|0"
@test 'false|false' (false|false; _status) = "$tide_status_failure_icon 1|1" @test 'false|false' (false|false; _status) = "$tide_status_failure_icon 1|1"
set -g tide_status_always_display_icon true
@test 'true' (true; _status) = "$tide_status_success_icon"
@test 'false' (false; _status) = "$tide_status_failure_icon 1"
@test 'true|false' (true|false; _status) = "$tide_status_failure_icon 0|1"
@test 'true|true' (true|true; _status) = "$tide_status_success_icon"
@test 'false|true' (false|true; _status) = "$tide_status_success_icon 1|0"
@test 'false|false' (false|false; _status) = "$tide_status_failure_icon 1|1"