Add option to make sound

This commit is contained in:
Roeniss Moon 2024-03-17 22:47:08 +09:00
parent f4766d6981
commit fc0e16d0f2
No known key found for this signature in database
GPG key ID: 2806329CE95C054D
3 changed files with 73 additions and 5 deletions

View file

@ -9,6 +9,10 @@
echo - "${@:3}"
}
function paplay {
echo - "paplay $1"
}
function uname {
echo - "Linux"
}
@ -92,6 +96,23 @@
assert "$lines[4]" same_as "--app-name=zsh --hint=int:transient:1 --urgency=normal --expire-time=15000"
}
@test 'auto-notify-send sends notification on Linux with sound' {
AUTO_COMMAND="f bar -r"
AUTO_COMMAND_FULL="foo bar -r"
AUTO_COMMAND_START=11080
AUTO_NOTIFY_EXPIRE_TIME=15000
AUTO_NOTIFY_SOUND=/usr/share/sounds/Yaru/stereo/bell.oga
run _auto_notify_send
assert $state equals 0
assert "$lines[1]" same_as 'Notification Title: "f bar -r" Completed'
assert "$lines[2]" same_as "Notification Body: Total time: 20 seconds"
assert "$lines[3]" same_as "Exit code: 0"
assert "$lines[4]" same_as "--app-name=zsh --hint=int:transient:1 --urgency=normal --expire-time=15000"
assert "$lines[5]" same_as "paplay /usr/share/sounds/Yaru/stereo/bell.oga"
}
@test 'auto-notify-send sends notification on macOS' {
AUTO_COMMAND="f bar -r"
AUTO_COMMAND_FULL="foo bar -r"
@ -112,6 +133,27 @@
assert "$lines[2]" same_as 'Exit code: 0 "f bar -r" Completed'
}
@test 'auto-notify-send sends notification on macOS with sound' {
AUTO_COMMAND="f bar -r"
AUTO_COMMAND_FULL="foo bar -r"
AUTO_COMMAND_START=11080
AUTO_NOTIFY_SOUND=Frog
function uname {
echo - "Darwin"
}
function osascript {
echo - "${@}"
}
run _auto_notify_send
assert $state equals 0
assert "$lines[1]" same_as '-e on run argv -e display notification (item 1 of argv) with title (item 2 of argv) sound name (item 3 of argv) -e end run Total time: 20 seconds'
assert "$lines[2]" same_as 'Exit code: 0 "f bar -r" Completed Frog'
}
@test 'auto-notify-send sends warning on unsupported platform' {
AUTO_COMMAND="f bar -r"
AUTO_COMMAND_FULL="foo bar -r"