mirror of
https://github.com/britzl/monarch.git
synced 2025-06-27 10:27:49 +02:00
Added additional tests and increased test framework version
This commit is contained in:
parent
57946d27bf
commit
b57609f061
@ -1,7 +1,7 @@
|
||||
[project]
|
||||
title = Monarch
|
||||
version = 0.9
|
||||
dependencies = https://github.com/britzl/deftest/archive/2.4.3.zip
|
||||
dependencies = https://github.com/britzl/deftest/archive/2.7.0.zip
|
||||
|
||||
[bootstrap]
|
||||
main_collection = /test/test.collectionc
|
||||
|
@ -5,5 +5,8 @@ local test_monarch = require "test.test_monarch"
|
||||
|
||||
function init(self)
|
||||
deftest.add(test_monarch)
|
||||
deftest.run({ coverage = { enabled = true }})
|
||||
deftest.run({
|
||||
coverage = { enabled = true },
|
||||
--pattern = "preload",
|
||||
})
|
||||
end
|
||||
|
@ -34,6 +34,14 @@ return function()
|
||||
return fn(...)
|
||||
end
|
||||
|
||||
local function wait_until_done(fn)
|
||||
local is_done = false
|
||||
local function done()
|
||||
is_done = true
|
||||
end
|
||||
fn(done)
|
||||
wait_timeout(function() return is_done end)
|
||||
end
|
||||
local function wait_until_visible(screen_id)
|
||||
return wait_timeout(is_visible, screen_id)
|
||||
end
|
||||
@ -302,6 +310,16 @@ return function()
|
||||
assert(wait_until_not_busy())
|
||||
end)
|
||||
|
||||
it("should be able to preload a screen and wait for it", function()
|
||||
assert(not monarch.is_preloading(TRANSITION1))
|
||||
monarch.preload(TRANSITION1)
|
||||
assert(monarch.is_preloading(TRANSITION1))
|
||||
wait_until_done(function(done)
|
||||
monarch.when_preloaded(TRANSITION1, done)
|
||||
end)
|
||||
assert(not monarch.is_preloading(TRANSITION1))
|
||||
end)
|
||||
|
||||
it("should ignore any preload calls while busy", function()
|
||||
monarch.show(TRANSITION1)
|
||||
-- previously a call to preload() while also showing a screen would
|
||||
@ -357,7 +375,12 @@ return function()
|
||||
assert(mock_msg.messages(URL1)[10].message.screen == SCREEN1)
|
||||
end)
|
||||
|
||||
|
||||
it("should be able to show a screen even while it is preloading", function()
|
||||
assert(monarch.is_preloading(SCREEN_PRELOAD))
|
||||
monarch.show(SCREEN_PRELOAD, nil, { count = 1 })
|
||||
assert(wait_until_shown(SCREEN_PRELOAD), "Screen_preload was never shown")
|
||||
end)
|
||||
|
||||
it("should be able to preload a screen and always keep it loaded", function()
|
||||
monarch.show(SCREEN_PRELOAD, nil, { count = 1 })
|
||||
assert(wait_until_shown(SCREEN_PRELOAD), "Screen_preload was never shown")
|
||||
|
Loading…
x
Reference in New Issue
Block a user