diff options
Diffstat (limited to 'tests/test_split.bats')
| -rw-r--r-- | tests/test_split.bats | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test_split.bats b/tests/test_split.bats new file mode 100644 index 0000000..798fa3f --- /dev/null +++ b/tests/test_split.bats @@ -0,0 +1,44 @@ +#!/usr/bin/env bats + +load '../vendor/bats-support/load' +load '../vendor/bats-assert/load' +load 'setup.sh' +load 'tmux.sh' + +TOGGLE_TERM_SCRIPT_PATH="$BATS_TEST_DIRNAME/../src/toggle-term.sh" + +# GIVEN a new tmux session with one pane +# WHEN we run toggle term split +# THEN we expect two panes with the new pane as active +@test 'split creates a new pane' { + assert_equal "$(tmux_pane_count)" '1' + assert_equal "$(tmux_active_panes)" '1' + + run "$TOGGLE_TERM_SCRIPT_PATH" split + assert_success + + assert_equal "$(tmux_pane_count)" '2' + assert_equal "$(tmux_active_panes)" '0-1' +} + +# GIVEN a new tmux session with one pane +# WHEN we run toggle term split twice +# THEN we expect two panes with the first pane as active +# and zoomed in so that the second pane is hidden. +# +# 'Zooming' is the mechanism we're using to have the first +# pane take up the whole screen again. When we unzoom, we can +# then see both panes again. +@test 'toggling split changes back active pane' { + assert_equal "$(tmux_pane_count)" '1' + assert_equal "$(tmux_active_panes)" '1' + + run "$TOGGLE_TERM_SCRIPT_PATH" split + assert_success + run "$TOGGLE_TERM_SCRIPT_PATH" split + assert_success + + assert_equal "$(tmux_pane_count)" '2' + assert_equal "$(tmux_active_panes)" '1-0' + assert_equal "$(tmux_is_zoomed)" 'true' +} |