From 88bad1e30895d3cbd2a4f922804cc2b2c6ef503b Mon Sep 17 00:00:00 2001 From: David Kaspar Date: Sat, 27 May 2023 22:35:34 +0100 Subject: [PATCH] added additional trivial tests --- .../amethyst/service/Nip05VerifierTest.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/src/test/java/com/vitorpamplona/amethyst/service/Nip05VerifierTest.kt b/app/src/test/java/com/vitorpamplona/amethyst/service/Nip05VerifierTest.kt index 52f8e5c6e..44d964ec8 100644 --- a/app/src/test/java/com/vitorpamplona/amethyst/service/Nip05VerifierTest.kt +++ b/app/src/test/java/com/vitorpamplona/amethyst/service/Nip05VerifierTest.kt @@ -6,6 +6,7 @@ import io.mockk.impl.annotations.SpyK import io.mockk.unmockkAll import org.junit.After import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull import org.junit.Assert.fail import org.junit.Before import org.junit.Test @@ -90,4 +91,31 @@ class Nip05VerifierTest { fun tearDown() { unmockkAll() } + + @Test + fun `test assmble url with invalid value returns null`() { + // given + val nip05address = "this@that@that.com" + + // when + val actualValue = nip05Verifier.assembleUrl(nip05address) + + // then + assertNull(actualValue) + } + + @Test + fun `test assmble url with valid value returns user url`() { + // given + val userName = "TheUser" + val domain = "domain.com" + val nip05address = "$userName@$domain" + val expectedValue = "https://$domain/.well-known/nostr.json?name=$userName" + + // when + val actualValue = nip05Verifier.assembleUrl(nip05address) + + // then + assertEquals(expectedValue, actualValue) + } }