mirror of
https://github.com/jimeh/tmuxifier.git
synced 2026-02-19 09:56:39 +00:00
Previously $window was only set by the new_window() helper when it was
passed a name argument. This caused weird behavior cause if it was
called without a name it would simply attempt to recreate the same
window and fail. That was until @blueyed's fix in 2249cf8.
However, the $window var still wasn't being set correctly, leaving
split_v(), split_h() and other helpers to operate on the wrong
window. This is no longer an issue as $window is always set to the index
of the currently active window at the end of new_window() and
select_window().
59 lines
1.7 KiB
Bash
Executable File
59 lines
1.7 KiB
Bash
Executable File
#! /usr/bin/env bash
|
|
source "../../test-helper.sh"
|
|
source "${root}/lib/layout-helpers.sh"
|
|
|
|
#
|
|
# new_window() tests.
|
|
#
|
|
|
|
# When called without arguments, creates new window.
|
|
create-test-session
|
|
stub __go_to_window_or_session_path
|
|
assert "test-socket-window-count" "1"
|
|
new_window
|
|
assert "test-socket-window-count" "2"
|
|
assert "stub_called_times __go_to_window_or_session_path" "1"
|
|
restore __go_to_window_or_session_path
|
|
kill-test-session
|
|
|
|
# When called with name argument, creates new window with specified name.
|
|
create-test-session
|
|
stub __go_to_window_or_session_path
|
|
assert "test-socket-window-count yippieezzz" "0"
|
|
new_window "yippieezzz"
|
|
assert "test-socket-window-count" "2"
|
|
assert "test-socket-window-count yippieezzz" "1"
|
|
restore __go_to_window_or_session_path
|
|
kill-test-session
|
|
|
|
# When called with name and command argument, creates new window with
|
|
# specified name and executes given command.
|
|
rm "/tmp/tmuxifier-new_window-test" &> /dev/null
|
|
create-test-session
|
|
stub __go_to_window_or_session_path
|
|
new_window "foobardoo" "touch /tmp/tmuxifier-new_window-test; bash"
|
|
assert "test-socket-window-count" "2"
|
|
assert "test-socket-window-count foobardoo" "1"
|
|
assert_raises 'test -f "/tmp/tmuxifier-new_window-test"' 0
|
|
restore __go_to_window_or_session_path
|
|
kill-test-session
|
|
rm "/tmp/tmuxifier-new_window-test" &> /dev/null
|
|
|
|
# When called ensure it sets the $window variable to the index of the newly
|
|
# created window.
|
|
unset window
|
|
create-test-session
|
|
stub __go_to_window_or_session_path
|
|
new_window "foo"
|
|
assert "echo $window" "1"
|
|
new_window
|
|
assert "echo $window" "2"
|
|
new_window "bar"
|
|
assert "echo $window" "3"
|
|
restore __go_to_window_or_session_path
|
|
kill-test-session
|
|
unset window
|
|
|
|
# End of tests.
|
|
assert_end "new_window()"
|