import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.test.getInstance
import net.pterodactylus.sone.test.mock
-import net.pterodactylus.sone.web.pages.WebPageTest
-import net.pterodactylus.sone.web.pages.CreateReplyPage
+import net.pterodactylus.sone.web.baseInjector
import net.pterodactylus.util.web.Method.POST
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.equalTo
+import org.hamcrest.Matchers.notNullValue
import org.junit.Test
import org.mockito.Mockito.verify
/**
* Unit test for [CreateReplyPage].
*/
-class CreateReplyPageTest: WebPageTest() {
-
- private val page = CreateReplyPage(template, webInterface)
- override fun getPage() = page
+class CreateReplyPageTest: WebPageTest(::CreateReplyPage) {
@Test
fun `page returns correct path`() {
@Test
fun `reply is created correctly`() {
- request("", POST)
+ setMethod(POST)
addHttpRequestPart("returnPage", "return.html")
addHttpRequestPart("post", "post-id")
addHttpRequestPart("text", "new text")
@Test
fun `reply is filtered`() {
- request("", POST)
+ setMethod(POST)
addHttpRequestPart("returnPage", "return.html")
addHttpRequestPart("post", "post-id")
addHttpRequestPart("text", "new http://localhost:12345/KSK@foo text")
@Test
fun `reply is created with correct sender`() {
- request("", POST)
+ setMethod(POST)
addHttpRequestPart("returnPage", "return.html")
addHttpRequestPart("post", "post-id")
addHttpRequestPart("text", "new text")
@Test
fun `empty text sets parameters in template contexty`() {
- request("", POST)
+ setMethod(POST)
addHttpRequestPart("returnPage", "return.html")
addHttpRequestPart("post", "post-id")
addHttpRequestPart("text", " ")
@Test
fun `user is redirected to no permissions page if post does not exist`() {
- request("", POST)
+ setMethod(POST)
addHttpRequestPart("returnPage", "return.html")
addHttpRequestPart("post", "post-id")
addHttpRequestPart("text", "new text")
verifyRedirect("noPermission.html")
}
+ @Test
+ fun `page can be created by dependency injection`() {
+ assertThat(baseInjector.getInstance<CreateReplyPage>(), notNullValue())
+ }
+
}