81 lines
2.0 KiB
Lua
81 lines
2.0 KiB
Lua
local test_helper = require('test.test_helper')
|
|
local mocks = test_helper.mocks
|
|
local utils = test_helper.utils
|
|
|
|
describe('Audio Module', function()
|
|
local audio
|
|
|
|
before_each(function()
|
|
audio = require('src.audio.init')
|
|
end)
|
|
|
|
it('should create purr sound', function()
|
|
local sound = audio.createPurrSound()
|
|
assert.are_equal('source', sound.type)
|
|
assert.is_true(sound.spatial)
|
|
assert.are_equal(5.0, sound.maxDistance)
|
|
end)
|
|
|
|
it('should create meow sound', function()
|
|
local sound = audio.createMeowSound()
|
|
assert.are_equal('source', sound.type)
|
|
assert.is_true(sound.spatial)
|
|
assert.are_equal(3.0, sound.maxDistance)
|
|
end)
|
|
|
|
it('should create click sound', function()
|
|
local sound = audio.createClickSound()
|
|
assert.are_equal('source', sound.type)
|
|
assert.is_true(sound.spatial)
|
|
assert.are_equal(2.0, sound.maxDistance)
|
|
end)
|
|
|
|
it('should create ambient sound', function()
|
|
local sound = audio.createAmbientSound()
|
|
assert.are_equal('source', sound.type)
|
|
assert.is_false(sound.spatial)
|
|
assert.is_true(sound.looping)
|
|
end)
|
|
|
|
it('should play purr at position', function()
|
|
audio.playPurr({ 1, 2, 3 })
|
|
end)
|
|
|
|
it('should play meow at position', function()
|
|
audio.playMeow({ 1, 2, 3 })
|
|
end)
|
|
|
|
it('should play click sound', function()
|
|
audio.playClick()
|
|
end)
|
|
|
|
it('should handle nil position in playPurr', function()
|
|
audio.playPurr(nil)
|
|
end)
|
|
|
|
it('should handle nil position in playMeow', function()
|
|
audio.playMeow(nil)
|
|
end)
|
|
|
|
it('should handle nil sounds', function()
|
|
audio.sounds = {}
|
|
audio.playPurr({ 1, 2, 3 })
|
|
audio.playMeow({ 1, 2, 3 })
|
|
end)
|
|
|
|
it('should handle nil sounds.purr', function()
|
|
audio.sounds.purr = nil
|
|
audio.playPurr({ 1, 2, 3 })
|
|
end)
|
|
|
|
it('should handle nil sounds.meow', function()
|
|
audio.sounds.meow = nil
|
|
audio.playMeow({ 1, 2, 3 })
|
|
end)
|
|
|
|
it('should handle nil sounds.click', function()
|
|
audio.sounds.click = nil
|
|
audio.playClick()
|
|
end)
|
|
end)
|