From efb336a23b65a9a2d56889396b13c1757bdaf354 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sun, 29 Dec 2019 14:58:33 -0300 Subject: Initial commit --- .../spacefish/tests/__sf_section_time.test.fish | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .config/fisher/github.com/matchai/spacefish/tests/__sf_section_time.test.fish (limited to '.config/fisher/github.com/matchai/spacefish/tests/__sf_section_time.test.fish') diff --git a/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_time.test.fish b/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_time.test.fish new file mode 100644 index 00000000..fe7ce215 --- /dev/null +++ b/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_time.test.fish @@ -0,0 +1,109 @@ +source $DIRNAME/spacefish_test_setup.fish + +function setup + spacefish_test_setup + + function date -a time_format + command date --version >/dev/null 2>/dev/null + switch $status + case 0 # GNU Coreutil + command date "-u" "-d @1536116421" "$time_format" + case '*' # MacOS + BSD Compatibility (Lacks --version) + command date "-u" "-r 1536116421" "$time_format" + end + end +end + +function teardown + functions --erase date +end + +test "Time is disabled by default?" + () = (__sf_section_time) +end + +test "Enabling time! 24-hour by default" + ( + set SPACEFISH_TIME_SHOW true + + set_color --bold + echo -n "at " + set_color normal + set_color --bold yellow + echo -n "03:00:21" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_time) +end + +test "Enabling time with 12-hour instead" + ( + set SPACEFISH_TIME_SHOW true + set SPACEFISH_TIME_12HR true + + set_color --bold + echo -n "at " + set_color normal + set_color --bold yellow + echo -n "03:00:21" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_time) +end + +test "Show the date too" + ( + set SPACEFISH_TIME_SHOW true + set SPACEFISH_DATE_SHOW true + + set_color --bold + echo -n "at " + set_color normal + set_color --bold yellow + echo -n "2018-09-05" + echo -n " " + echo -n "03:00:21" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_time) +end + +test "Custom date/time format" + ( + set SPACEFISH_TIME_SHOW true + set SPACEFISH_TIME_FORMAT (date '+%H') # Unix timestamp + set SPACEFISH_TIME_PREFIX "" # Get rid of "at " prefix. + + set_color --bold + set_color normal + set_color --bold yellow + echo -n "03" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_time) +end + +test "What is the time? Purple?!" + ( + set SPACEFISH_TIME_SHOW true + set SPACEFISH_TIME_COLOR purple + + set_color --bold + echo -n "at " + set_color normal + set_color --bold purple + echo -n "03:00:21" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_time) +end -- cgit v1.2.3