From: David ‘Bombe’ Roden Date: Tue, 20 Jun 2017 12:34:52 +0000 (+0200) Subject: Convert bookmarks page test to use new web page test base X-Git-Tag: 0.9.7^2~116 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e409df7786c9d4556c8c754a447e494fbd95d32a;p=Sone.git Convert bookmarks page test to use new web page test base --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt index f0a9d49..04446a2 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt @@ -13,9 +13,8 @@ import org.junit.Test /** * Unit test for [BookmarksPage]. */ -class BookmarksPageTest: WebPageTest() { +class BookmarksPageTest: WebPageTest2(::BookmarksPage) { - private val page = BookmarksPage(template, webInterface) private val post1 = createLoadedPost(1000) private val post2 = createLoadedPost(3000) private val post3 = createLoadedPost(2000) @@ -39,20 +38,22 @@ class BookmarksPageTest: WebPageTest() { @Test @Suppress("UNCHECKED_CAST") fun `page sets correct posts in template context`() { - page.processTemplate(freenetRequest, templateContext) - assertThat(templateContext["posts"] as Collection, contains(post2, post3, post1)) - assertThat((templateContext["pagination"] as Pagination).items, contains(post2, post3, post1)) - assertThat(templateContext["postsNotLoaded"], equalTo(false)) + verifyNoRedirect { + assertThat(templateContext["posts"] as Collection, contains(post2, post3, post1)) + assertThat((templateContext["pagination"] as Pagination).items, contains(post2, post3, post1)) + assertThat(templateContext["postsNotLoaded"], equalTo(false)) + } } @Test @Suppress("UNCHECKED_CAST") fun `page does not put unloaded posts in template context but sets a flag`() { whenever(post3.isLoaded).thenReturn(false) - page.processTemplate(freenetRequest, templateContext) - assertThat(templateContext["posts"] as Collection, contains(post2, post1)) - assertThat((templateContext["pagination"] as Pagination).items, contains(post2, post1)) - assertThat(templateContext["postsNotLoaded"], equalTo(true)) + verifyNoRedirect { + assertThat(templateContext["posts"] as Collection, contains(post2, post1)) + assertThat((templateContext["pagination"] as Pagination).items, contains(post2, post1)) + assertThat(templateContext["postsNotLoaded"], equalTo(true)) + } } }