99 lines
2.5 KiB
Lua
99 lines
2.5 KiB
Lua
local test_helper = require('test.test_helper')
|
|
local mocks = test_helper.mocks
|
|
local utils = test_helper.utils
|
|
|
|
describe('UI Module', function()
|
|
local ui
|
|
local core
|
|
|
|
before_each(function()
|
|
ui = require('src.ui.init')
|
|
mocks.setupFilesystem()
|
|
core = require('src.core')
|
|
end)
|
|
|
|
it('should render HUD', function()
|
|
local pass = utils.createMockPass()
|
|
ui.renderHUD(pass)
|
|
end)
|
|
|
|
it('should render HUD with zero cats', function()
|
|
core.state.cats = {}
|
|
local pass = utils.createMockPass()
|
|
ui.renderHUD(pass)
|
|
end)
|
|
|
|
it('should render inventory', function()
|
|
local pass = utils.createMockPass()
|
|
ui.renderInventory(pass, 1280, 720, 0.72)
|
|
end)
|
|
|
|
it('should render cat log', function()
|
|
local pass = utils.createMockPass()
|
|
ui.renderCatLog(pass, 1280, 0.72)
|
|
end)
|
|
|
|
it('should render placement preview', function()
|
|
local pass = utils.createMockPass()
|
|
ui.renderPlacementPreview(pass, 1280, 720)
|
|
end)
|
|
|
|
it('should get world ray', function()
|
|
local start, endPos = ui.getWorldRay(1280, 720)
|
|
assert.are.equal('table', type(start))
|
|
assert.are.equal('table', type(endPos))
|
|
end)
|
|
|
|
it('should handle mouse press in inventory', function()
|
|
ui.showInventory = true
|
|
ui.selectedFurniture = nil
|
|
ui.handleMousePress(1000, 500, 1)
|
|
end)
|
|
|
|
it('should handle mouse press on close button', function()
|
|
ui.showInventory = true
|
|
ui.handleMousePress(1200, 300, 1)
|
|
assert.is_false(ui.showInventory)
|
|
end)
|
|
|
|
it('should toggle inventory', function()
|
|
ui.toggleInventory()
|
|
assert.is_true(ui.showInventory)
|
|
ui.toggleInventory()
|
|
assert.is_false(ui.showInventory)
|
|
end)
|
|
|
|
it('should toggle cat log', function()
|
|
ui.toggleCatLog()
|
|
assert.is_false(ui.showCatLog)
|
|
ui.toggleCatLog()
|
|
assert.is_true(ui.showCatLog)
|
|
end)
|
|
|
|
it('should handle nil core in renderHUD', function()
|
|
_G.core = nil
|
|
local pass = utils.createMockPass()
|
|
ui.renderHUD(pass)
|
|
end)
|
|
|
|
it('should handle nil pass in renderHUD', function()
|
|
ui.renderHUD(nil)
|
|
end)
|
|
|
|
it('should handle nil pass in renderInventory', function()
|
|
ui.renderInventory(nil, 1280, 720, 0.72)
|
|
end)
|
|
|
|
it('should handle nil pass in renderCatLog', function()
|
|
ui.renderCatLog(nil, 1280, 0.72)
|
|
end)
|
|
|
|
it('should handle nil pass in renderPlacementPreview', function()
|
|
ui.renderPlacementPreview(nil, 1280, 720)
|
|
end)
|
|
|
|
it('should handle nil core in handleMousePress', function()
|
|
ui.handleMousePress(100, 100, 1)
|
|
end)
|
|
end)
|