#!/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' }