feat: add system sound alert module
Made-with: Cursor
This commit is contained in:
20
tests/test_sound.py
Normal file
20
tests/test_sound.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock
|
||||
from cursor_flasher.sound import play_alert
|
||||
from cursor_flasher.config import Config
|
||||
|
||||
|
||||
class TestPlayAlert:
|
||||
def test_does_nothing_when_disabled(self):
|
||||
config = Config(sound_enabled=False)
|
||||
play_alert(config)
|
||||
|
||||
@patch("cursor_flasher.sound.NSSound")
|
||||
def test_plays_named_sound(self, mock_nssound):
|
||||
mock_sound_obj = MagicMock()
|
||||
mock_nssound.soundNamed_.return_value = mock_sound_obj
|
||||
config = Config(sound_enabled=True, sound_name="Glass", sound_volume=0.7)
|
||||
play_alert(config)
|
||||
mock_nssound.soundNamed_.assert_called_once_with("Glass")
|
||||
mock_sound_obj.setVolume_.assert_called_once_with(0.7)
|
||||
mock_sound_obj.play.assert_called_once()
|
||||
Reference in New Issue
Block a user