From 4c13175469f8e98e8b1e048500e8ee65bf434d52 Mon Sep 17 00:00:00 2001 From: Jay Ohms Date: Tue, 27 Feb 2024 16:26:13 -0500 Subject: [PATCH] Add a test to ensure that a resolved location with a trailing slash passing along the bridge message --- .../dev/hotwire/strada/BridgeDelegateTest.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/strada/src/test/kotlin/dev/hotwire/strada/BridgeDelegateTest.kt b/strada/src/test/kotlin/dev/hotwire/strada/BridgeDelegateTest.kt index 7156430..76f9b42 100644 --- a/strada/src/test/kotlin/dev/hotwire/strada/BridgeDelegateTest.kt +++ b/strada/src/test/kotlin/dev/hotwire/strada/BridgeDelegateTest.kt @@ -77,6 +77,23 @@ class BridgeDelegateTest { assertNotNull(delegate.component()) } + @Test + fun bridgeDidReceiveMessageForLocationWithTrailingSlash() { + whenever(webView.url).thenReturn("https://37signals.com/") + + val message = Message( + id = "1", + component = "one", + event = "connect", + metadata = Metadata("https://37signals.com/"), + jsonData = """{"title":"Page-title","subtitle":"Page-subtitle"}""" + ) + + assertNull(delegate.component()) + assertEquals(true, delegate.bridgeDidReceiveMessage(message)) + assertNotNull(delegate.component()) + } + @Test fun bridgeDidReceiveMessageForResolvedLocation() { whenever(webView.url).thenReturn("https://37signals.com/new_url")