mirror of
https://github.com/britzl/monarch.git
synced 2025-09-27 18:12:22 +02:00
Implement monarch.replace() (#61)
This commit is contained in:
@@ -133,6 +133,22 @@ return function()
|
||||
assert_stack({ })
|
||||
end)
|
||||
|
||||
it("should be able to replace screens at the top of the stack", function()
|
||||
monarch.show(SCREEN1_STR)
|
||||
assert(wait_until_shown(SCREEN1), "Screen1 was never shown")
|
||||
assert_stack({ SCREEN1 })
|
||||
|
||||
monarch.show(SCREEN2)
|
||||
assert(wait_until_hidden(SCREEN1), "Screen1 was never hidden")
|
||||
assert(wait_until_shown(SCREEN2), "Screen2 was never shown")
|
||||
assert_stack({ SCREEN1, SCREEN2 })
|
||||
|
||||
monarch.replace(SCREEN1)
|
||||
assert(wait_until_hidden(SCREEN2), "Screen2 was never hidden")
|
||||
assert(wait_until_shown(SCREEN1), "Screen1 was never shown")
|
||||
assert_stack({ SCREEN1, SCREEN1 })
|
||||
end)
|
||||
|
||||
it("should be able to tell if a screen is visible or not", function()
|
||||
assert(not monarch.is_visible(SCREEN1))
|
||||
monarch.show(SCREEN1)
|
||||
@@ -302,6 +318,20 @@ return function()
|
||||
assert_stack({ SCREEN1, SCREEN2 })
|
||||
end)
|
||||
|
||||
it("should close any open popups when replacing a non-popup", function()
|
||||
monarch.show(SCREEN1)
|
||||
assert(wait_until_shown(SCREEN1), "Screen1 was never shown")
|
||||
assert_stack({ SCREEN1 })
|
||||
monarch.show(POPUP1)
|
||||
assert(wait_until_shown(POPUP1), "Popup1 was never shown")
|
||||
assert_stack({ SCREEN1, POPUP1 })
|
||||
monarch.show(POPUP2)
|
||||
assert(wait_until_shown(POPUP2), "Popup2 was never shown")
|
||||
assert_stack({ SCREEN1, POPUP1, POPUP2 })
|
||||
monarch.replace(SCREEN2)
|
||||
assert(wait_until_shown(SCREEN2), "Popup2 was never shown")
|
||||
assert_stack({ SCREEN2 })
|
||||
end)
|
||||
|
||||
it("should be able to get the id of the screen at the top and bottom of the stack", function()
|
||||
assert(monarch.top() == nil)
|
||||
|
Reference in New Issue
Block a user