Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add tests for case insensitive
  • Loading branch information
Ben Trengrove committed Mar 17, 2021
commit 99f1ba8a299659cd29c2f10da2176def61cbc753
Original file line number Diff line number Diff line change
Expand Up @@ -1049,4 +1049,51 @@ class NavDeepLinkTest {
.that(matchArgs?.getInt("id"))
.isEqualTo(id)
}

@Test
fun deepLinkCaseInsensitiveDomain() {
bentrengrove marked this conversation as resolved.
Outdated
Show resolved Hide resolved
val deepLinkString = DEEP_LINK_EXACT_HTTP
val deepLink = NavDeepLink(deepLinkString)

val deepLinkUpper = deepLinkString.toUpperCase()
assertThat(deepLink.matches(Uri.parse(deepLinkUpper)))
}

@Test
fun deepLinkCaseInsensitiveDomainRegexMatching() {
bentrengrove marked this conversation as resolved.
Outdated
Show resolved Hide resolved
val deepLinkArgument = "$DEEP_LINK_EXACT_HTTPS/users?path=go/to/{path}"
val deepLink = NavDeepLink(deepLinkArgument)

val path = "directions"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("${DEEP_LINK_EXACT_HTTPS.toUpperCase()}/users?path=go/to/"),
mapOf("path" to stringArgument(path))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
.isNotNull()
assertWithMessage("Args should not contain the path")
.that(matchArgs?.containsKey("path"))
.isFalse()
}

@Test
fun deepLinkCaseSensitiveParams() {
bentrengrove marked this conversation as resolved.
Outdated
Show resolved Hide resolved
val deepLinkString = "$DEEP_LINK_EXACT_HTTP/?myParam={param}"
val deepLink = NavDeepLink(deepLinkString)

val param = 2
val deepLinkUpper = deepLinkString
.replace("myParam", "MyParam")
bentrengrove marked this conversation as resolved.
Outdated
Show resolved Hide resolved
.replace("{param}", param.toString())
val matchArgs = deepLink.getMatchingArguments(Uri.parse(deepLinkUpper),
mapOf("param" to intArgument()))

assertWithMessage("Args should be not be null")
.that(matchArgs)
.isNotNull()
assertWithMessage("Args bundle should be empty")
.that(matchArgs!!.isEmpty)
bentrengrove marked this conversation as resolved.
Outdated
Show resolved Hide resolved
.isTrue()
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.