diff --git a/js/src/test/scala/com/raquo/waypoint/BasePathSpec.scala b/js/src/test/scala/com/raquo/waypoint/BasePathSpec.scala index aca5d50..c7ab94f 100644 --- a/js/src/test/scala/com/raquo/waypoint/BasePathSpec.scala +++ b/js/src/test/scala/com/raquo/waypoint/BasePathSpec.scala @@ -163,18 +163,20 @@ class BasePathSpec extends UnitSpec { ) it("segment routes - parse urls - match") { - def testHomeRoute(homeRoute: Route[HomePage.type, Unit]) = { - if (basePath.nonEmpty) { - expectPageRelative(homeRoute, origin, s"$basePath", Some(HomePage)) - } else { - // (basePath + url) must be a relative URL, so if basePath is empty, url can't also be empty, it must start with `/` - expectPageRelativeFailure(homeRoute, origin, s"$basePath") + def testHomeRoute(homeRoute: Route[HomePage.type, Unit], clue: String) = { + withClue(clue) { + if (basePath.nonEmpty) { + expectPageRelative(homeRoute, origin, s"$basePath", Some(HomePage)) + } else { + // (basePath + url) must be a relative URL, so if basePath is empty, url can't also be empty, it must start with `/` + expectPageRelativeFailure(homeRoute, origin, s"$basePath") + } + expectPageRelative(homeRoute, origin, s"$basePath/", Some(HomePage)) } - expectPageRelative(homeRoute, origin, s"$basePath/", Some(HomePage)) } - testHomeRoute(homeRoute) - testHomeRoute(homeRouteTotal) + testHomeRoute(homeRoute, clue = "homeRoute") + testHomeRoute(homeRouteTotal, clue = "homeRouteTotal") expectPageRelative(libraryRoute, origin, s"$basePath/app/library/1234", Some(LibraryPage(libraryId = 1234))) expectPageRelative(libraryRoute, origin, s"$basePath/app/library/100?hello=world", Some(LibraryPage(libraryId = 100))) @@ -202,14 +204,16 @@ class BasePathSpec extends UnitSpec { expectPageRelative(libraryRoute, origin, "/app/library/1234", if (basePath.isEmpty) Some(LibraryPage(1234)) else None) - def testHomeRoute(homeRoute: Route[HomePage.type, Unit]) = { - if (Utils.basePathHasEmptyFragment(basePath)) { - val basePathWithoutFragment = Utils.basePathWithoutFragment(basePath) - expectPageRelative(homeRoute, origin, s"$basePathWithoutFragment", Some(HomePage)) + def testHomeRoute(homeRoute: Route[HomePage.type, Unit], clue: String) = { + withClue(clue) { + if (Utils.basePathHasEmptyFragment(basePath)) { + val basePathWithoutFragment = Utils.basePathWithoutFragment(basePath) + expectPageRelative(homeRoute, origin, s"$basePathWithoutFragment", Some(HomePage)) + } } } - testHomeRoute(homeRoute) - testHomeRoute(homeRouteTotal) + testHomeRoute(homeRoute, clue = "homeRoute") + testHomeRoute(homeRouteTotal, clue = "homeRouteTotal") // @TODO[API] I mean... these are not absolute urls... expectPageAbsoluteFailure(libraryRoute, origin, "//app/library/1234")