Add unit tests for mounting relative to -2

To satisfy https://github.com/Textualize/textual/pull/1095#discussion_r1013041338
This commit is contained in:
Dave Pearson
2022-11-03 15:49:15 +00:00
parent 3a771fb3b1
commit b0d2caf221

View File

@@ -37,6 +37,20 @@ async def test_mount_via_app() -> None:
await pilot.app.mount(ultimate, after=-1)
assert pilot.app.screen.children[-1] == ultimate
async with App().run_test() as pilot:
# Mount a widget before -2, which is "before the penultimate".
penpenultimate = Static(id="penpenultimate")
await pilot.app.mount_all(widgets)
await pilot.app.mount(penpenultimate, before=-2)
assert pilot.app.screen.children[-3] == penpenultimate
async with App().run_test() as pilot:
# Mount a widget after -2, which is "before the end".
penultimate = Static(id="penultimate")
await pilot.app.mount_all(widgets)
await pilot.app.mount(penultimate, after=-2)
assert pilot.app.screen.children[-2] == penultimate
async with App().run_test() as pilot:
# Mount a widget before 0, which is "at the start".
start = Static(id="start")