package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.*
+import net.pterodactylus.sone.data.impl.*
import net.pterodactylus.sone.freenet.wot.*
import net.pterodactylus.sone.test.*
import net.pterodactylus.sone.utils.*
/**
* Unit test for [KnownSonesPage].
*/
-class KnownSonesPageTest: WebPageTest(::KnownSonesPage) {
+class KnownSonesPageTest : WebPageTest(::KnownSonesPage) {
private val sones = listOf(
createSone(1000, 4, 7, 2, "sone2", true, true),
whenever(this.time).thenReturn(time)
whenever(this.posts).thenReturn((0..(posts - 1)).map { mock<Post>() })
whenever(this.replies).thenReturn((0..(replies - 1)).map { mock<PostReply>() }.toSet())
- val album = mock<Album>()
- whenever(album.images).thenReturn(((0..(images - 1)).map { mock<Image>() }))
- val rootAlbum = mock<Album>().apply {
- whenever(albums).thenReturn(listOf(album))
+ val album = AlbumImpl(this)
+ repeat(images) {
+ ImageImpl().modify().setSone(this).update()
+ .also(album::addImage)
}
+ val rootAlbum = AlbumImpl(this).also { it.addAlbum(album) }
whenever(this.rootAlbum).thenReturn(rootAlbum)
whenever(this.profile).thenReturn(mock())
whenever(id).thenReturn(name.toLowerCase())
@Test
fun `page returns correct title`() {
- whenever(l10n.getString("Page.KnownSones.Title")).thenReturn("known sones page title")
+ addTranslation("Page.KnownSones.Title", "known sones page title")
assertThat(page.getPageTitle(soneRequest), equalTo("known sones page title"))
}
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<KnownSonesPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<KnownSonesPage>(), notNullValue())
}
@Test
fun `page is annotated with the correct menuname`() {
- assertThat(page.menuName, equalTo("KnownSones"))
+ assertThat(page.menuName, equalTo("KnownSones"))
}
@Test
fun `page is annotated with corrrect template path`() {
- assertThat(page.templatePath, equalTo("/templates/knownSones.html"))
+ assertThat(page.templatePath, equalTo("/templates/knownSones.html"))
}
}