/**
* Unit test for [ViewPostPage].
*/
-class ViewPostPageTest: WebPageTest() {
+class ViewPostPageTest: WebPageTest2(::ViewPostPage) {
- private val page = ViewPostPage(template, webInterface)
private val post = mock<Post>()
- override fun getPage() = page
-
@Test
fun `page returns correct path`() {
assertThat(page.path, equalTo("viewPost.html"))
import freenet.clients.http.ToadletContext
import freenet.support.api.HTTPRequest
import net.pterodactylus.sone.core.Preferences
+import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.Sone
import net.pterodactylus.sone.test.deepMock
import net.pterodactylus.sone.test.get
private val toadletContext = deepMock<ToadletContext>()
private val getRequestParameters = mutableMapOf<String, MutableList<String>>()
private val allSones = mutableMapOf<String, Sone>()
+ private val allPosts = mutableMapOf<String, Post>()
private val translations = mutableMapOf<String, String>()
@Before
whenever(core.preferences).thenReturn(preferences)
whenever(core.sones).then { allSones.values }
whenever(core.getSone(anyString())).then { allSones[it[0]].asOptional() }
+ whenever(core.getPost(anyString())).then { allPosts[it[0]].asOptional() }
}
@Before
allSones[id] = sone
}
+ fun addPost(id: String, post: Post) {
+ allPosts[id] = post
+ }
+
fun addTranslation(key: String, value: String) {
translations[key] = value
}