/**
* Unit test for [ImageBrowserPage].
*/
-class ImageBrowserPageTest : WebPageTest() {
-
- private val page = ImageBrowserPage(template, webInterface)
+class ImageBrowserPageTest: WebPageTest2(::ImageBrowserPage) {
@Test
fun `page returns correct path`() {
addAlbum("album-id", album)
addHttpRequestParameter("album", "album-id")
addHttpRequestParameter("page", "5")
- page.processTemplate(freenetRequest, templateContext)
- assertThat(templateContext["albumRequested"], equalTo<Any>(true))
- assertThat(templateContext["album"], equalTo<Any>(album))
- assertThat(templateContext["page"], equalTo<Any>("5"))
+ verifyNoRedirect {
+ assertThat(templateContext["albumRequested"], equalTo<Any>(true))
+ assertThat(templateContext["album"], equalTo<Any>(album))
+ assertThat(templateContext["page"], equalTo<Any>("5"))
+ }
}
@Test
val image = mock<Image>()
addImage("image-id", image)
addHttpRequestParameter("image", "image-id")
- page.processTemplate(freenetRequest, templateContext)
- assertThat(templateContext["imageRequested"], equalTo<Any>(true))
- assertThat(templateContext["image"], equalTo<Any>(image))
+ verifyNoRedirect {
+ assertThat(templateContext["imageRequested"], equalTo<Any>(true))
+ assertThat(templateContext["image"], equalTo<Any>(image))
+ }
}
@Test
val sone = mock<Sone>()
addSone("sone-id", sone)
addHttpRequestParameter("sone", "sone-id")
- page.processTemplate(freenetRequest, templateContext)
- assertThat(templateContext["soneRequested"], equalTo<Any>(true))
- assertThat(templateContext["sone"], equalTo<Any>(sone))
+ verifyNoRedirect {
+ assertThat(templateContext["soneRequested"], equalTo<Any>(true))
+ assertThat(templateContext["sone"], equalTo<Any>(sone))
+ }
}
@Test
val secondSone = createSone("third album", "fourth album")
addSone("sone2", secondSone)
addHttpRequestParameter("mode", "gallery")
- page.processTemplate(freenetRequest, templateContext)
- assertThat(templateContext["galleryRequested"], equalTo<Any>(true))
- @Suppress("UNCHECKED_CAST")
- assertThat(templateContext["albums"] as Iterable<Album>, contains(
- firstSone.rootAlbum.albums[0],
- secondSone.rootAlbum.albums[1],
- firstSone.rootAlbum.albums[1],
- secondSone.rootAlbum.albums[0]
- ))
+ verifyNoRedirect {
+ assertThat(templateContext["galleryRequested"], equalTo<Any>(true))
+ @Suppress("UNCHECKED_CAST")
+ assertThat(templateContext["albums"] as Iterable<Album>, contains(
+ firstSone.rootAlbum.albums[0],
+ secondSone.rootAlbum.albums[1],
+ firstSone.rootAlbum.albums[1],
+ secondSone.rootAlbum.albums[0]
+ ))
+ }
}
private fun createSone(firstAlbumTitle: String, secondAlbumTitle: String): Sone {
@Test
fun `requesting nothing will show the albums of the current sone`() {
- page.processTemplate(freenetRequest, templateContext)
- assertThat(templateContext["soneRequested"], equalTo<Any>(true))
- assertThat(templateContext["sone"], equalTo<Any>(currentSone))
+ verifyNoRedirect {
+ assertThat(templateContext["soneRequested"], equalTo<Any>(true))
+ assertThat(templateContext["sone"], equalTo<Any>(currentSone))
+ }
}
@Test