mirror of
https://github.com/ivuorinen/nvm-auto-use.fish.git
synced 2026-02-08 16:48:16 +00:00
- Major refactor of core Fish functions for modularity, caching, and error handling - Improved `.editorconfig` and Makefile for stricter formatting and linting standards - Expanded linting support: added EditorConfig checks, auto-install for missing tools, and Makefile targets - Enhanced CI workflow with clearer permissions and job steps in GitHub Actions - Updated documentation in `README.md` and `CLAUDE.md` to reflect new features, advanced developer tools, and contribution guidelines - Improved Node.js version manager detection, switching, and installation logic - Added/updated utility functions for configuration, silent mode, notifications, and version extraction - Various bug fixes, code quality improvements, and expanded test coverage
110 lines
3.2 KiB
Fish
110 lines
3.2 KiB
Fish
#!/usr/bin/env fish
|
|
# Unit tests for nvm_auto_use_config helper functions
|
|
|
|
source tests/test_runner.fish
|
|
|
|
function test_config_show
|
|
echo "Testing _nvm_auto_use_config_show..."
|
|
|
|
# Should print config summary (no error)
|
|
_nvm_auto_use_config_show
|
|
and echo "✅ Config show prints summary"
|
|
or echo "❌ Config show failed"
|
|
end
|
|
|
|
function test_config_auto_install
|
|
echo "Testing _nvm_auto_use_config_auto_install..."
|
|
|
|
_nvm_auto_use_config_auto_install on
|
|
test -z "$_nvm_auto_use_no_install"
|
|
and echo "✅ Auto-install enabled"
|
|
or echo "❌ Auto-install enable failed"
|
|
|
|
_nvm_auto_use_config_auto_install off
|
|
test -n "$_nvm_auto_use_no_install"
|
|
and echo "✅ Auto-install disabled"
|
|
or echo "❌ Auto-install disable failed"
|
|
end
|
|
|
|
function test_config_silent
|
|
echo "Testing _nvm_auto_use_config_silent..."
|
|
|
|
_nvm_auto_use_config_silent on
|
|
test -n "$_nvm_auto_use_silent"
|
|
and echo "✅ Silent mode enabled"
|
|
or echo "❌ Silent mode enable failed"
|
|
|
|
_nvm_auto_use_config_silent off
|
|
test -z "$_nvm_auto_use_silent"
|
|
and echo "✅ Silent mode disabled"
|
|
or echo "❌ Silent mode disable failed"
|
|
end
|
|
|
|
function test_config_debounce
|
|
echo "Testing _nvm_auto_use_config_debounce..."
|
|
|
|
_nvm_auto_use_config_debounce 1234
|
|
assert_equals "$_nvm_auto_use_debounce_ms" 1234 "Debounce set correctly"
|
|
|
|
_nvm_auto_use_config_debounce ""
|
|
assert_equals "$_nvm_auto_use_debounce_ms" 1234 "Debounce unchanged on invalid input"
|
|
end
|
|
|
|
function test_config_exclude_include
|
|
echo "Testing _nvm_auto_use_config_exclude and _nvm_auto_use_config_include..."
|
|
|
|
set -e _nvm_auto_use_excluded_dirs
|
|
_nvm_auto_use_config_exclude testdir
|
|
assert_contains "$_nvm_auto_use_excluded_dirs" testdir "Exclude added"
|
|
|
|
_nvm_auto_use_config_include testdir
|
|
assert_not_equals "$_nvm_auto_use_excluded_dirs" testdir "Exclude removed"
|
|
end
|
|
|
|
function test_config_manager
|
|
echo "Testing _nvm_auto_use_config_manager..."
|
|
|
|
_nvm_auto_use_config_manager nvm
|
|
assert_equals "$_nvm_auto_use_preferred_manager" nvm "Manager set to nvm"
|
|
|
|
_nvm_auto_use_config_manager ""
|
|
test -z "$_nvm_auto_use_preferred_manager"
|
|
and echo "✅ Manager reset to auto-detect"
|
|
or echo "❌ Manager reset failed"
|
|
|
|
_nvm_auto_use_config_manager invalid
|
|
assert_not_equals "$_nvm_auto_use_preferred_manager" invalid "Invalid manager not set"
|
|
end
|
|
|
|
function test_config_reset
|
|
echo "Testing _nvm_auto_use_config_reset..."
|
|
|
|
set -g _nvm_auto_use_no_install 1
|
|
set -g _nvm_auto_use_silent 1
|
|
set -g _nvm_auto_use_debounce_ms 999
|
|
set -g _nvm_auto_use_excluded_dirs foo
|
|
set -g _nvm_auto_use_preferred_manager nvm
|
|
|
|
_nvm_auto_use_config_reset
|
|
|
|
test -z "$_nvm_auto_use_no_install"
|
|
and test -z "$_nvm_auto_use_silent"
|
|
and test -z "$_nvm_auto_use_debounce_ms"
|
|
and test -z "$_nvm_auto_use_excluded_dirs"
|
|
and test -z "$_nvm_auto_use_preferred_manager"
|
|
and echo "✅ Config reset works"
|
|
or echo "❌ Config reset failed"
|
|
end
|
|
|
|
function main
|
|
test_config_show
|
|
test_config_auto_install
|
|
test_config_silent
|
|
test_config_debounce
|
|
test_config_exclude_include
|
|
test_config_manager
|
|
test_config_reset
|
|
end
|
|
|
|
main
|