Skip to content

Commit

Permalink
test: added test to show network name case-insensitive search
Browse files Browse the repository at this point in the history
  • Loading branch information
Ugo Amanoh committed Dec 17, 2019
1 parent 0388ef4 commit 7ff682d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/me/uport/sdk/core/Networks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ object Networks {
*/
private fun getNetworkByName(name: String): EthNetwork? {
for ((_, value) in NETWORK_CONFIG) {
if (value.name.toLowerCase() === name.toLowerCase()) {
if (value.name.toLowerCase() == name.toLowerCase()) {
return value
}
}
Expand Down
14 changes: 5 additions & 9 deletions core/src/test/java/me/uport/sdk/core/NetworksTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,14 @@ class NetworksTest {
}

@Test
fun `throws error if the network name does not match`() {
assertThat {
Networks.get("manet")
}.thrownError {
isInstanceOf(IllegalStateException::class)
}
fun `can find a registered network using the different case name`() {
assertThat(Networks.get("MainNet")).isEqualTo(Networks.mainnet)
}

@Test
fun `throws error if the network name cases does not match`() {
@Test
fun `throws error if the network name does not match`() {
assertThat {
Networks.get("Mainnet")
Networks.get("manet")
}.thrownError {
isInstanceOf(IllegalStateException::class)
}
Expand Down

0 comments on commit 7ff682d

Please sign in to comment.