diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-11-23 18:32:47 -0800 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-11-23 18:32:47 -0800 |
| commit | cd3885855692653a4ac7a48adabc60009e70a8ef (patch) | |
| tree | 0c60a3a4bb3e6c14f72dd550ca9d7ca08019ac64 /tests/test_config.bats | |
| parent | Fix format of installation config in readme file (diff) | |
| download | tmux-toggle-term-cd3885855692653a4ac7a48adabc60009e70a8ef.zip | |
Change toggle term float and split key defaults
- `@toggle-term-float-key` now defaults to `f`.
- `@toggle-term-split-key` now defaults to `;`.
Diffstat (limited to 'tests/test_config.bats')
| -rw-r--r-- | tests/test_config.bats | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/tests/test_config.bats b/tests/test_config.bats new file mode 100644 index 0000000..6396815 --- /dev/null +++ b/tests/test_config.bats @@ -0,0 +1,129 @@ +#!/usr/bin/env bats + +load '../vendor/bats-support/load' +load '../vendor/bats-assert/load' +load 'setup.sh' +load 'tmux.sh' + +load_plugin() { + "$BATS_TEST_DIRNAME/../src/main.sh" +} + +@test 'plugin loads with default key bindings' { + run load_plugin + assert_success + + run tmux_has_prefix_binding "f" "float" + assert_success + run tmux_has_prefix_binding ";" "split" + assert_success +} + +@test 'custom float key without prefix works' { + tmux_set_option "@toggle-term-float-key" "M-f" + tmux_set_option "@toggle-term-float-use-prefix" "false" + + run load_plugin + assert_success + + run tmux_has_root_binding "M-f" "float" + assert_success +} + +@test 'custom split key without prefix works' { + tmux_set_option "@toggle-term-split-key" "M-t" + tmux_set_option "@toggle-term-split-use-prefix" "false" + + run load_plugin + assert_success + + run tmux_has_root_binding "M-t" "split" + assert_success +} + +@test 'custom float key with prefix works' { + tmux_set_option "@toggle-term-float-key" "f" + tmux_set_option "@toggle-term-float-use-prefix" "true" + + run load_plugin + assert_success + + run tmux_has_prefix_binding "f" "float" + assert_success +} + +@test 'custom split key with prefix works' { + tmux_set_option "@toggle-term-split-key" "s" + tmux_set_option "@toggle-term-split-use-prefix" "true" + + run load_plugin + assert_success + + run tmux_has_prefix_binding "s" "split" + assert_success +} + +@test 'mixed prefix configuration works' { + tmux_set_option "@toggle-term-float-key" "f" + tmux_set_option "@toggle-term-float-use-prefix" "true" + tmux_set_option "@toggle-term-split-key" "C-t" + tmux_set_option "@toggle-term-split-use-prefix" "false" + + run load_plugin + assert_success + + run tmux_has_prefix_binding "f" "float" + assert_success + run tmux_has_root_binding "C-t" "split" + assert_success +} + +@test 'prefix can be disabled for both keys' { + tmux_set_option "@toggle-term-float-use-prefix" "false" + tmux_set_option "@toggle-term-split-use-prefix" "false" + + run load_plugin + assert_success + + run tmux_has_root_binding "f" "float" + assert_success + run tmux_has_root_binding ";" "split" + assert_success +} + +@test 'float can be disabled' { + tmux_set_option "@toggle-term-float-enabled" "false" + + run load_plugin + assert_success + + run tmux_has_prefix_binding "f" "float" + assert_failure + run tmux_has_prefix_binding ";" "split" + assert_success +} + +@test 'split can be disabled' { + tmux_set_option "@toggle-term-split-enabled" "false" + + run load_plugin + assert_success + + run tmux_has_prefix_binding "f" "float" + assert_success + run tmux_has_prefix_binding ";" "split" + assert_failure +} + +@test 'both float and split can be disabled' { + tmux_set_option "@toggle-term-float-enabled" "false" + tmux_set_option "@toggle-term-split-enabled" "false" + + run load_plugin + assert_success + + run tmux_has_prefix_binding "f" "float" + assert_failure + run tmux_has_prefix_binding ";" "split" + assert_failure +} |