From 2a96890414f3380d56fc3f526269c438bffa97aa Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 25 May 2017 13:27:13 +0200 Subject: [PATCH] Add more tests for options page --- .../sone/web/pages/OptionsPageTest.kt | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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 dc73874..be9f54b 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt @@ -110,7 +110,7 @@ class OptionsPageTest: WebPageTest() { setMethod(POST) addHttpRequestPart("show-custom-avatars", "ALWAYS") addHttpRequestPart("load-linked-images", "ALWAYS") - addHttpRequestPart(option, setValue.toString()) + setValue?.also { addHttpRequestPart(option, it.toString()) } verifyRedirect("options.html") { assertThat(getter(), equalTo(expectedValue)) } @@ -122,26 +122,52 @@ class OptionsPageTest: WebPageTest() { } @Test + fun `auto-follow option can be unset`() { + verifyThatOptionCanBeSet("auto-follow", null, false) { currentSone.options.isAutoFollow } + } + + @Test fun `show new sone notification option can be set`() { verifyThatOptionCanBeSet("show-notification-new-sones", "checked", true) { currentSone.options.isShowNewSoneNotifications } } @Test + fun `show new sone notification option can be unset`() { + verifyThatOptionCanBeSet("" + + "", null, false) { currentSone.options.isShowNewSoneNotifications } + } + + @Test fun `show new post notification option can be set`() { verifyThatOptionCanBeSet("show-notification-new-posts", "checked", true) { currentSone.options.isShowNewPostNotifications } } @Test + fun `show new post notification option can be unset`() { + verifyThatOptionCanBeSet("show-notification-new-posts", null, false) { currentSone.options.isShowNewPostNotifications } + } + + @Test fun `show new reply notification option can be set`() { verifyThatOptionCanBeSet("show-notification-new-replies", "checked", true) { currentSone.options.isShowNewReplyNotifications } } @Test + fun `show new reply notification option can be unset`() { + verifyThatOptionCanBeSet("show-notification-new-replies", null, false) { currentSone.options.isShowNewReplyNotifications } + } + + @Test fun `enable sone insert notifications option can be set`() { verifyThatOptionCanBeSet("enable-sone-insert-notifications", "checked", true) { currentSone.options.isSoneInsertNotificationEnabled } } @Test + fun `enable sone insert notifications option can be unset`() { + verifyThatOptionCanBeSet("enable-sone-insert-notifications", null, false) { currentSone.options.isSoneInsertNotificationEnabled } + } + + @Test fun `load linked images option can be set`() { verifyThatOptionCanBeSet("load-linked-images", "TRUSTED", TRUSTED) { currentSone.options.loadLinkedImages } } -- 2.7.4