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=d2929d9175b7936b3031018eef8f143d9060e30a;hp=ecee2f49fa84db13daf3b108ef0e074308fab48c;hb=faf66247a34f64946990a985d2ea3003465969cb;hpb=87482530f0361af55a17780981d6819269aada67 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 ecee2f4..d2929d9 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt @@ -1,28 +1,21 @@ package net.pterodactylus.sone.web.pages -import net.pterodactylus.sone.data.SoneOptions.DefaultSoneOptions -import net.pterodactylus.sone.data.SoneOptions.LoadExternalContent.FOLLOWED -import net.pterodactylus.sone.data.SoneOptions.LoadExternalContent.TRUSTED +import net.pterodactylus.sone.data.SoneOptions.* +import net.pterodactylus.sone.data.SoneOptions.LoadExternalContent.* +import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.* 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.sone.test.* +import net.pterodactylus.sone.web.* import net.pterodactylus.sone.web.page.* -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 +import net.pterodactylus.util.web.Method.* +import org.hamcrest.MatcherAssert.* +import org.hamcrest.Matchers.* +import org.junit.* /** * Unit test for [OptionsPage]. */ -class OptionsPageTest: WebPageTest(::OptionsPage) { +class OptionsPageTest : WebPageTest(::OptionsPage) { @Before fun setupPreferences() { @@ -32,11 +25,8 @@ class OptionsPageTest: WebPageTest(::OptionsPage) { 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 @@ -84,11 +74,8 @@ class OptionsPageTest: WebPageTest(::OptionsPage) { assertThat(templateContext["images-per-page"], equalTo(4)) assertThat(templateContext["fcp-interface-active"], equalTo(true)) assertThat(templateContext["require-full-access"], equalTo(true)) - assertThat(templateContext["negative-trust"], equalTo(7)) - assertThat(templateContext["positive-trust"], equalTo(8)) assertThat(templateContext["post-cut-off-length"], equalTo(51)) assertThat(templateContext["posts-per-page"], equalTo(10)) - assertThat(templateContext["trust-comment"], equalTo("11")) } } @@ -291,56 +278,6 @@ class OptionsPageTest: WebPageTest(::OptionsPage) { } @Test - fun `negative trust can not be set to -101`() { - verifyThatWrongValueForPreferenceIsDetected("negative-trust", "-101") - } - - @Test - fun `negative trust can be set to -100`() { - verifyThatPreferencesCanBeSet("negative-trust", "-100", -100) { core.preferences.negativeTrust } - } - - @Test - fun `negative trust can be set to 100`() { - verifyThatPreferencesCanBeSet("negative-trust", "100", 100) { core.preferences.negativeTrust } - } - - @Test - fun `negative trust can not be set to 101`() { - verifyThatWrongValueForPreferenceIsDetected("negative-trust", "101") - } - - @Test - fun `negative trust is set to default on invalid value`() { - verifyThatPreferencesCanBeSet("negative-trust", "invalid", -25) { core.preferences.negativeTrust } - } - - @Test - fun `positive trust can not be set to -1`() { - verifyThatWrongValueForPreferenceIsDetected("positive-trust", "-1") - } - - @Test - fun `positive trust can be set to 0`() { - verifyThatPreferencesCanBeSet("positive-trust", "0", 0) { core.preferences.positiveTrust } - } - - @Test - fun `positive trust can be set to 100`() { - verifyThatPreferencesCanBeSet("positive-trust", "100", 100) { core.preferences.positiveTrust } - } - - @Test - fun `positive trust can not be set to 101`() { - verifyThatWrongValueForPreferenceIsDetected("positive-trust", "101") - } - - @Test - fun `positive trust is set to default on invalid value`() { - verifyThatPreferencesCanBeSet("positive-trust", "invalid", 75) { core.preferences.positiveTrust } - } - - @Test fun `post cut off length can not be set to -49`() { verifyThatWrongValueForPreferenceIsDetected("post-cut-off-length", "-49") } @@ -371,23 +308,18 @@ class OptionsPageTest: WebPageTest(::OptionsPage) { } @Test - fun `trust comment can be set`() { - verifyThatPreferencesCanBeSet("trust-comment", "trust", "trust") { core.preferences.trustComment } - } - - @Test - fun `trust comment is set to default when set to empty value`() { - verifyThatPreferencesCanBeSet("trust-comment", "", "Set from Sone Web Interface") { core.preferences.trustComment } + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) } @Test - fun `page can be created by dependency injection`() { - assertThat(baseInjector.getInstance(), notNullValue()) + fun `page is annotated with correct menuname`() { + assertThat(page.menuName, equalTo("Options")) } @Test - fun `page is annotated with correct menuname`() { - assertThat(page.menuName, equalTo("Options")) + fun `page is annotated with correct template path`() { + assertThat(page.templatePath, equalTo("/templates/options.html")) } }