1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.test.*
4 import net.pterodactylus.sone.web.*
5 import net.pterodactylus.sone.web.page.*
6 import net.pterodactylus.util.web.Method.*
7 import org.hamcrest.MatcherAssert.*
8 import org.hamcrest.Matchers.*
10 import org.mockito.Mockito.*
13 * Unit test for [DeleteSonePage].
15 class DeleteSonePageTest : WebPageTest(::DeleteSonePage) {
18 fun `page returns correct path`() {
19 assertThat(page.path, equalTo("deleteSone.html"))
23 fun `page requires login`() {
24 assertThat(page.requiresLogin(), equalTo(true))
28 fun `page returns correct title`() {
29 addTranslation("Page.DeleteSone.Title", "delete sone page")
30 assertThat(page.getPageTitle(soneRequest), equalTo("delete sone page"))
34 fun `get request does not redirect`() {
35 page.processTemplate(freenetRequest, templateContext)
39 fun `post request without delete confirmation redirects to index`() {
41 verifyRedirect("index.html") {
42 verify(core, never()).deleteSone(any())
47 fun `post request with delete confirmation deletes sone and redirects to index`() {
49 addHttpRequestPart("deleteSone", "true")
50 verifyRedirect("index.html") {
51 verify(core).deleteSone(currentSone)
56 fun `page can be created by dependency injection`() {
57 assertThat(baseInjector.getInstance<DeleteSonePage>(), notNullValue())
61 fun `page is annotated with correct menuname`() {
62 assertThat(page.menuName, equalTo("DeleteSone"))
66 fun `page is annotated with correct template path`() {
67 assertThat(page.templatePath, equalTo("/templates/deleteSone.html"))