X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FCreateSonePageTest.kt;h=e865f653752852ff8ccb6d3711d5b723791340cb;hp=9cbf2c3139fdf6484f9db7576f9c961ebc6be9ba;hb=110a933c2724aba6a604fc5eed6372ff1e1e6144;hpb=ffd92ca2374c0b2218e583d02e0bdd24b8c110ae diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt index 9cbf2c3..e865f65 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt @@ -3,12 +3,16 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Profile import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.freenet.wot.OwnIdentity +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever +import net.pterodactylus.sone.web.baseInjector +import net.pterodactylus.sone.web.page.* import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.contains import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.junit.Test import org.mockito.ArgumentMatchers.anyString import org.mockito.Mockito.verify @@ -16,7 +20,7 @@ import org.mockito.Mockito.verify /** * Unit test for [CreateSonePage]. */ -class CreateSonePageTest: WebPageTest(::CreateSonePage) { +class CreateSonePageTest : WebPageTest(::CreateSonePage) { private val localSones_ = listOf( createSone("local-sone1"), @@ -111,7 +115,7 @@ class CreateSonePageTest: WebPageTest(::CreateSonePage) { @Test fun `create sone is not shown in menu if full access is required but client doesn’t have full access`() { - core.preferences.isRequireFullAccess = true + core.preferences.newRequireFullAccess = true assertThat(page.isEnabled(toadletContext), equalTo(false)) } @@ -136,10 +140,25 @@ class CreateSonePageTest: WebPageTest(::CreateSonePage) { @Test fun `create sone is shown in menu if no sone is logged in and client has full access`() { - core.preferences.isRequireFullAccess = true + core.preferences.newRequireFullAccess = true whenever(toadletContext.isAllowedFullAccess).thenReturn(true) unsetCurrentSone() assertThat(page.isEnabled(toadletContext), equalTo(true)) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + + @Test + fun `page is annotated with the correct menuname`() { + assertThat(page.menuName, equalTo("CreateSone")) + } + + @Test + fun `page is annotated with the correct template path`() { + assertThat(page.templatePath, equalTo("/templates/createSone.html")) + } + }