summaryrefslogtreecommitdiff
path: root/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_git_status.test.fish
diff options
context:
space:
mode:
Diffstat (limited to '.config/fisher/github.com/matchai/spacefish/tests/__sf_section_git_status.test.fish')
-rw-r--r--.config/fisher/github.com/matchai/spacefish/tests/__sf_section_git_status.test.fish129
1 files changed, 129 insertions, 0 deletions
diff --git a/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_git_status.test.fish b/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_git_status.test.fish
new file mode 100644
index 00000000..91c6fd5d
--- /dev/null
+++ b/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_git_status.test.fish
@@ -0,0 +1,129 @@
+source $DIRNAME/spacefish_test_setup.fish
+
+function setup
+ spacefish_test_setup
+ mkdir -p /tmp/tmp-spacefish
+ cd /tmp/tmp-spacefish
+ command git init >/dev/null
+ command git config --local user.email "test@example.com"
+ command git config --local user.name "Test User"
+end
+
+function teardown
+ rm -rf /tmp/tmp-spacefish
+end
+
+test "Displays no status symbols in a clean repo"
+ () = (__sf_section_git_status)
+end
+
+test "Displays the correct symbol for untracked file"
+ (
+ touch testfile
+
+ set_color --bold
+ set_color normal
+ set_color --bold red
+ echo -n " [?]"
+ set_color normal
+ set_color --bold
+ set_color normal
+ ) = (__sf_section_git_status)
+end
+
+test "Displays the correct symbol for added file"
+ (
+ touch testfile
+ command git add testfile
+
+ set_color --bold
+ set_color normal
+ set_color --bold red
+ echo -n " [+]"
+ set_color normal
+ set_color --bold
+ set_color normal
+ ) = (__sf_section_git_status)
+end
+
+test "Displays the correct symbol for modified file"
+ (
+ touch testfile
+ command git add testfile
+ command git commit -m "Initial commit" --quiet
+ echo "modification" > testfile
+
+ set_color --bold
+ set_color normal
+ set_color --bold red
+ echo -n " [!]"
+ set_color normal
+ set_color --bold
+ set_color normal
+ ) = (__sf_section_git_status)
+end
+
+test "Displays the correct symbol for renamed file"
+ (
+ touch testfile
+ command git add testfile
+ command git commit -m "Initial commit" --quiet
+ mv testfile newtestfile
+ command git add testfile newtestfile
+
+ set_color --bold
+ set_color normal
+ set_color --bold red
+ echo -n " [»]"
+ set_color normal
+ set_color --bold
+ set_color normal
+ ) = (__sf_section_git_status)
+end
+
+test "Displays the correct symbol for deleted file"
+ (
+ touch testfile
+ command git add testfile
+ command git commit -m "Initial commit" --quiet
+ rm testfile
+ command git add testfile
+
+ set_color --bold
+ set_color normal
+ set_color --bold red
+ echo -n " [✘]"
+ set_color normal
+ set_color --bold
+ set_color normal
+ ) = (__sf_section_git_status)
+end
+
+test "Displays the correct symbol for stashed file"
+ (
+ touch testfile
+ command git add testfile
+ command git commit -m "Initial commit" --quiet
+ echo "modification" > testfile
+ command git stash --quiet
+
+ set_color --bold
+ set_color normal
+ set_color --bold red
+ echo -n " [\$]"
+ set_color normal
+ set_color --bold
+ set_color normal
+ ) = (__sf_section_git_status)
+end
+
+test "Test config option SPACEFISH_GIT_STATUS_SHOW"
+ (
+ set -g SPACEFISH_GIT_STATUS_SHOW false
+ ) = (__sf_section_git_status)
+end
+
+# TODO: Get test dir into status *U*
+# TODO: Add test for ahead
+# TODO: Add test for behind
+# TODO: Add test for diverged