Skip to content

Commit

Permalink
Component.toPrettyString() now uses TestingLifecycleHook.getLabel()
Browse files Browse the repository at this point in the history
  • Loading branch information
mvysny committed Jun 8, 2023
1 parent 40614df commit 9b64462
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Expand Up @@ -88,7 +88,8 @@ public fun Component.toPrettyString(): String {
if (!isEnabled) {
list.add("DISABLED")
}
if (label.isNotBlank()) {
val label = testingLifecycleHook.getLabel(this)
if (!label.isNullOrBlank()) {
list.add("label='$label'")
}
if (!_text.isNullOrBlank()) {
Expand Down Expand Up @@ -156,12 +157,6 @@ public fun Component.toPrettyString(): String {
list.add("CLOSED")
}
}
if (this is SideNav) {
list.add("label='$label'")
}
if (this is SideNavItem) {
list.add("label='$label'")
}
if (this.javaClass.hasCustomToString()) {
// by default Vaadin components do not introduce toString() at all;
// toString() therefore defaults to Object's toString() which is useless. However,
Expand Down
Expand Up @@ -56,7 +56,7 @@ fun DynaNodeGroup.sideNavTests() {

test("toPrettyString()") {
expect("SideNav[label='label']") { SideNav("label").toPrettyString() }
expect("SideNavItem[@path='login', label='foo']") { SideNavItem("foo", LoginView::class.java).toPrettyString() }
expect("SideNavItem[@path='admin', label='bar']") { SideNavItem("bar", "admin").toPrettyString() }
expect("SideNavItem[label='foo', @path='login']") { SideNavItem("foo", LoginView::class.java).toPrettyString() }
expect("SideNavItem[label='bar', @path='admin']") { SideNavItem("bar", "admin").toPrettyString() }
}
}

0 comments on commit 9b64462

Please sign in to comment.