Skip to content

Commit fef5f7a

Browse files
committed
test sub titles
1 parent 3d9923d commit fef5f7a

File tree

3 files changed

+172
-1
lines changed

3 files changed

+172
-1
lines changed

src/textual/app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,11 @@ def format_title(self, title: str, sub_title: str) -> Content:
977977
title_content = Content(title)
978978
sub_title_content = Content(sub_title)
979979
if sub_title_content:
980-
return Content.assemble(title_content, " — ", sub_title_content)
980+
return Content.assemble(
981+
title_content,
982+
(" — ", "dim"),
983+
sub_title_content.stylize("dim"),
984+
)
981985
else:
982986
return title_content
983987

Lines changed: 151 additions & 0 deletions
Loading

tests/snapshot_tests/test_snapshots.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4610,3 +4610,19 @@ def compose(self) -> ComposeResult:
46104610
yield TextArea(placeholder="Your text here")
46114611

46124612
assert snap_compare(TextApp())
4613+
4614+
4615+
def test_header_format(snap_compare):
4616+
"""Test title and sub-title are formatted as expected.
4617+
4618+
You should see "Title - Sub-title" in the header. Where sub-title is dimmed.
4619+
"""
4620+
4621+
class HeaderApp(App):
4622+
TITLE = "Title"
4623+
SUB_TITLE = "Sub-title"
4624+
4625+
def compose(self) -> ComposeResult:
4626+
yield Header()
4627+
4628+
assert snap_compare(HeaderApp())

0 commit comments

Comments
 (0)