From: David ‘Bombe’ Roden Date: Fri, 5 May 2017 20:49:20 +0000 (+0200) Subject: Add test for index page without any posts X-Git-Tag: 0.9.7^2~222 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=2d2f89a8dc40e68ee4ce747074c4c518ac2b246f;ds=sidebyside Add test for index page without any posts --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt index 990aacf..6d87f3a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt @@ -11,6 +11,7 @@ import net.pterodactylus.sone.utils.Pagination import net.pterodactylus.util.web.Method.GET import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.contains +import org.hamcrest.Matchers.emptyIterable import org.hamcrest.Matchers.equalTo import org.junit.Before import org.junit.Test @@ -146,4 +147,15 @@ class IndexPageTest : WebPageTest() { assertThat((templateContext["pagination"] as Pagination).page, equalTo(2)) } + @Test + fun `index page without posts sets correct pagination`() { + request("", GET) + core.preferences.postsPerPage = 1 + page.processTemplate(freenetRequest, templateContext) + @Suppress("UNCHECKED_CAST") + (templateContext["pagination"] as Pagination).let { pagination -> + assertThat(pagination.items, emptyIterable()) + } + } + }