mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
Inline helper.is_enabled, remove unused code, documentation fixes, remove formats and druid_input files, add more tests
This commit is contained in:
40
test/tests/test_back_handler.lua
Normal file
40
test/tests/test_back_handler.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
local mock_gui = require "deftest.mock.gui"
|
||||
local mock_time = require("deftest.mock.time")
|
||||
local mock_input = require("test.helper.mock_input")
|
||||
local test_helper = require("test.helper.test_helper")
|
||||
local druid_system = require("druid.druid")
|
||||
|
||||
return function()
|
||||
local druid = nil
|
||||
local context = test_helper.get_context()
|
||||
describe("Back Handler component", function()
|
||||
before(function()
|
||||
mock_gui.mock()
|
||||
mock_time.mock()
|
||||
mock_time.set(60)
|
||||
druid = druid_system.new(context)
|
||||
end)
|
||||
|
||||
after(function()
|
||||
mock_gui.unmock()
|
||||
mock_time.unmock()
|
||||
druid:final(context)
|
||||
druid = nil
|
||||
end)
|
||||
|
||||
it("Should react on back action id with custom args", function()
|
||||
local on_back_handler, on_back_handler_mock = test_helper.get_function()
|
||||
druid:new_back_handler(on_back_handler, { args = "custom" })
|
||||
|
||||
druid:on_input(mock_input.key_pressed("key_back"))
|
||||
druid:on_input(mock_input.key_released("key_back"))
|
||||
assert(on_back_handler_mock.calls == 1)
|
||||
assert(on_back_handler_mock.params[1] == context)
|
||||
assert(on_back_handler_mock.params[2].args == "custom")
|
||||
|
||||
druid:on_input(mock_input.key_pressed("key_a"))
|
||||
druid:on_input(mock_input.key_released("key_a"))
|
||||
assert(on_back_handler_mock.calls == 1)
|
||||
end)
|
||||
end)
|
||||
end
|
Reference in New Issue
Block a user