X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FOptionsPageTest.kt;h=88755492c4ba0cc18cd777cb8ebe8b9a993050bf;hp=4e4c02e0f426f8b4ea392407d07555f94b4b36ef;hb=3db634e425d3482bcf00dfd82e4b0d46785d5959;hpb=ffd92ca2374c0b2218e583d02e0bdd24b8c110ae diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt index 4e4c02e..8875549 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt @@ -6,11 +6,14 @@ import net.pterodactylus.sone.data.SoneOptions.LoadExternalContent.TRUSTED import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.ALWAYS import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.NO import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.WRITING +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.whenever +import net.pterodactylus.sone.web.baseInjector import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import org.hamcrest.Matchers.hasItem +import org.hamcrest.Matchers.notNullValue import org.hamcrest.Matchers.nullValue import org.junit.Before import org.junit.Test @@ -22,17 +25,17 @@ class OptionsPageTest: WebPageTest(::OptionsPage) { @Before fun setupPreferences() { - core.preferences.insertionDelay = 1 - core.preferences.charactersPerPost = 50 - core.preferences.fcpFullAccessRequired = WRITING - core.preferences.imagesPerPage = 4 - core.preferences.isFcpInterfaceActive = true - core.preferences.isRequireFullAccess = true - core.preferences.negativeTrust = 7 - core.preferences.positiveTrust = 8 - core.preferences.postCutOffLength = 51 - core.preferences.postsPerPage = 10 - core.preferences.trustComment = "11" + core.preferences.newInsertionDelay = 1 + core.preferences.newCharactersPerPost = 50 + core.preferences.newFcpFullAccessRequired = WRITING + core.preferences.newImagesPerPage = 4 + core.preferences.newFcpInterfaceActive = true + core.preferences.newRequireFullAccess = true + core.preferences.newNegativeTrust = 7 + core.preferences.newPositiveTrust = 8 + core.preferences.newPostCutOffLength = 51 + core.preferences.newPostsPerPage = 10 + core.preferences.newTrustComment = "11" } @Before @@ -61,7 +64,7 @@ class OptionsPageTest: WebPageTest(::OptionsPage) { @Test fun `page returns correct title`() { addTranslation("Page.Options.Title", "options page title") - assertThat(page.getPageTitle(freenetRequest), equalTo("options page title")) + assertThat(page.getPageTitle(soneRequest), equalTo("options page title")) } @Test @@ -268,22 +271,22 @@ class OptionsPageTest: WebPageTest(::OptionsPage) { @Test fun `fcp interface can be set to true`() { - verifyThatPreferencesCanBeSet("fcp-interface-active", "checked", true) { core.preferences.isFcpInterfaceActive } + verifyThatPreferencesCanBeSet("fcp-interface-active", "checked", true) { core.preferences.fcpInterfaceActive } } @Test fun `fcp interface can be set to false`() { - verifyThatPreferencesCanBeSet("fcp-interface-active", null, false) { core.preferences.isFcpInterfaceActive } + verifyThatPreferencesCanBeSet("fcp-interface-active", null, false) { core.preferences.fcpInterfaceActive } } @Test fun `require full access can be set to true`() { - verifyThatPreferencesCanBeSet("require-full-access", "checked", true) { core.preferences.isRequireFullAccess } + verifyThatPreferencesCanBeSet("require-full-access", "checked", true) { core.preferences.requireFullAccess } } @Test fun `require full access can be set to false`() { - verifyThatPreferencesCanBeSet("require-full-access", null, false) { core.preferences.isRequireFullAccess } + verifyThatPreferencesCanBeSet("require-full-access", null, false) { core.preferences.requireFullAccess } } @Test @@ -376,4 +379,9 @@ class OptionsPageTest: WebPageTest(::OptionsPage) { verifyThatPreferencesCanBeSet("trust-comment", "", "Set from Sone Web Interface") { core.preferences.trustComment } } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }