Add tests for __go_to_window_or_session_path layout helper

This commit is contained in:
2014-06-03 20:01:47 +01:00
parent 8a06ad149e
commit 636e92b118

View File

@@ -0,0 +1,49 @@
#! /usr/bin/env bash
source "../../test-helper.sh"
source "${root}/lib/layout-helpers.sh"
#
# __go_to_window_or_session_path() tests.
#
# When neither $window_root or $session_root are set, does nothing.
stub run_cmd
__go_to_window_or_session_path
assert "stub_called_times run_cmd" "0"
restore run_cmd
# When only $window_root is set, runs cd to $window_root path.
stub run_cmd
window_root="/tmp"
__go_to_window_or_session_path
assert 'stub_called_with_times run_cmd cd \"/tmp\"' "1"
assert 'stub_called_with_times run_cmd clear' "1"
unset window_root
restore run_cmd
# When only $session_root is set, runs cd to $session_root path.
stub run_cmd
session_root="/usr"
__go_to_window_or_session_path
assert 'stub_called_with_times run_cmd cd \"/usr\"' "1"
assert 'stub_called_with_times run_cmd clear' "1"
unset session_root
restore run_cmd
# When $window_root and $session_root are set, runs cd to $window_root path.
stub run_cmd
window_root="/tmp"
session_root="/usr"
__go_to_window_or_session_path
assert 'stub_called_with_times run_cmd cd \"/tmp\"' "1"
assert 'stub_called_with_times run_cmd clear' "1"
unset window_root
unset session_root
restore run_cmd
# End of tests.
assert_end "__go_to_window_or_session_path()"