summaryrefslogtreecommitdiff
path: root/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_time.test.fish
blob: fe7ce215a447b8088b81067ecdf5f477e52740ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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