3
0
mirror of https://github.com/britzl/monarch.git synced 2025-06-27 02:17:53 +02:00

Added monarch.is_popup() (#70)

This commit is contained in:
Björn Ritzl 2021-02-14 11:53:52 +01:00 committed by GitHub
parent 5771a40e68
commit a19bdd78e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -188,6 +188,17 @@ function M.is_visible(id)
end
--- Check if a screen is a popup
-- @param id Screen id
-- @return true if the screen is a popup
function M.is_popup(id)
assert(id, "You must provide a screen id")
id = tohash(id)
assert(screens[id], ("There is no screen registered with id %s"):format(tostring(id)))
return screens[id].popup
end
local function register(id, settings)
assert(id, "You must provide a screen id")
id = tohash(id)

View File

@ -572,5 +572,11 @@ return function()
local ok, err = monarch.post(POPUP1, "foobar")
assert(not ok and err, "Expected monarch.post() to return false plus an error message")
end)
it("should be able to check if a screen is is a popup", function()
assert(not monarch.is_popup(SCREEN1))
assert(monarch.is_popup(POPUP1))
end)
end)
end