feat: add plugins for zsh

This commit is contained in:
2024-09-22 20:14:22 +04:00
parent f4c1c54e72
commit 6c85cc3b71
515 changed files with 30838 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
#!/usr/bin/env zunit
@setup {
load "../you-should-use.plugin.zsh"
unset YSU_MESSAGE_POSITION
_YSU_BUFFER=""
}
@teardown {
rm -f output.txt
}
# We work around not being able to use `run` AND test variable values by redirecting
# all output to a temporary file from which we can read.
@test 'ysu - _write_ysu_buffer before' {
YSU_MESSAGE_POSITION="before"
export _YSU_BUFFER
_write_ysu_buffer "hello world" 2> output.txt
assert $state equals 0
assert "$(< output.txt)" same_as "hello world"
assert "$_YSU_BUFFER" is_empty
}
@test 'ysu - _write_ysu_buffer after' {
YSU_MESSAGE_POSITION="after"
export _YSU_BUFFER
_write_ysu_buffer "hello world" 2> output.txt
assert $state equals 0
assert "$(< output.txt)" is_empty
assert "$_YSU_BUFFER" same_as "hello world"
}
@test 'ysu - _write_ysu_buffer invalid' {
YSU_MESSAGE_POSITION="invalid"
export _YSU_BUFFER
_write_ysu_buffer "" 2> output.txt
assert $state equals 0
expected="$(tput setaf 1)$(tput bold)Unknown value for YSU_MESSAGE_POSITION 'invalid'. "
expected+="Expected value 'before' or 'after'$(tput sgr0)\n"
assert "$(< output.txt)" same_as "$expected"
assert "$_YSU_BUFFER" is_empty
}