summaryrefslogtreecommitdiff
path: root/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_time.test.fish
diff options
context:
space:
mode:
authorRoger Gonzalez <rogergonzalez21@gmail.com>2019-12-29 14:58:33 -0300
committerRoger Gonzalez <rogergonzalez21@gmail.com>2019-12-29 14:58:33 -0300
commitefb336a23b65a9a2d56889396b13c1757bdaf354 (patch)
tree234e40115f79a84c8a755df6fb932cc6797e36e1 /.config/fisher/github.com/matchai/spacefish/tests/__sf_section_time.test.fish
Initial commit
Diffstat (limited to '.config/fisher/github.com/matchai/spacefish/tests/__sf_section_time.test.fish')
-rw-r--r--.config/fisher/github.com/matchai/spacefish/tests/__sf_section_time.test.fish109
1 files changed, 109 insertions, 0 deletions
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