diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-11-23 18:32:47 -0800 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-11-26 20:21:16 -0800 |
| commit | 78c397c3f7a9eea0f764c66270f47613f8e015d3 (patch) | |
| tree | ebaa4d1bcf595719c55167deadd7847452ebedfe /tests/test_split.bats | |
| parent | Fix format of installation config in readme file (diff) | |
| download | tmux-toggle-term-78c397c3f7a9eea0f764c66270f47613f8e015d3.zip | |
Refactor bats tests
Diffstat (limited to '')
| -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' +} |