summaryrefslogtreecommitdiff
path: root/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_elixir.test.fish
blob: 5c411f23019213678f2e48c7831c31e8ab203731 (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
110
source $DIRNAME/spacefish_test_setup.fish

function setup
	spacefish_test_setup
	mock elixir -v 0 "echo \"Erlang/OTP 21 [erts-10.3.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]
Elixir 1.8.1 (compiled with Erlang/OTP 21)\""
	set -x ELIXIR_VERSION 1.8.1
	mkdir -p /tmp/tmp-spacefish
	cd /tmp/tmp-spacefish
end

function teardown
	rm -rf /tmp/tmp-spacefish
end

test "Prints section when mix.exs is present"
	(
		touch /tmp/tmp-spacefish/mix.exs

		set_color --bold
		echo -n "via "
		set_color normal
		set_color --bold magenta
		echo -n "💧 v1.8.1"
		set_color normal
		set_color --bold
		echo -n " "
		set_color normal
	) = (__sf_section_elixir)
end

test "Prints section when a *.ex file is present"
	(
		touch /tmp/tmp-spacefish/testfile.ex

		set_color --bold
		echo -n "via "
		set_color normal
		set_color --bold magenta
		echo -n "💧 v1.8.1"
		set_color normal
		set_color --bold
		echo -n " "
		set_color normal
	) = (__sf_section_elixir)
end

test "Doesn't print the section when mix.exs and *.ex aren't present"
	() = (__sf_section_elixir)
end

test "Changing SPACEFISH_ELIXIR_SYMBOL changes the displayed character"
	(
		touch /tmp/tmp-spacefish/mix.exs
		set SPACEFISH_ELIXIR_SYMBOL "· "

		set_color --bold
		echo -n "via "
		set_color normal
		set_color --bold magenta
		echo -n "· v1.8.1"
		set_color normal
		set_color --bold
		echo -n " "
		set_color normal
	) = (__sf_section_elixir)
end

test "Changing SPACEFISH_ELIXIR_PREFIX changes the character prefix"
	(
		touch /tmp/tmp-spacefish/mix.exs
		set sf_exit_code 0
		set SPACEFISH_ELIXIR_PREFIX ·

		set_color --bold
		echo -n "·"
		set_color normal
		set_color --bold magenta
		echo -n "💧 v1.8.1"
		set_color normal
		set_color --bold
		echo -n " "
		set_color normal
	) = (__sf_section_elixir)
end

test "Changing SPACEFISH_ELIXIR_SUFFIX changes the character suffix"
	(
		touch /tmp/tmp-spacefish/mix.exs
		set sf_exit_code 0
		set SPACEFISH_ELIXIR_SUFFIX ·

		set_color --bold
		echo -n "via "
		set_color normal
		set_color --bold magenta
		echo -n "💧 v1.8.1"
		set_color normal
		set_color --bold
		echo -n "·"
		set_color normal
	) = (__sf_section_elixir)
end

test "doesn't display the section when SPACEFISH_ELIXIR_SHOW is set to \"false\""
	(
		touch /tmp/tmp-spacefish/mix.exs
		set SPACEFISH_ELIXIR_SHOW false
	) = (__sf_section_elixir)
end