projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
♻️ Move Page.menuName property to more appropriate file
[Sone.git]
/
src
/
test
/
kotlin
/
net
/
pterodactylus
/
sone
/
web
/
pages
/
IndexPageTest.kt
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt
index
b51627d
..
2a72bb3
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt
@@
-5,13
+5,17
@@
import com.google.common.base.Predicate
import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.Sone
import net.pterodactylus.sone.notify.PostVisibilityFilter
import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.Sone
import net.pterodactylus.sone.notify.PostVisibilityFilter
+import net.pterodactylus.sone.test.getInstance
import net.pterodactylus.sone.test.mock
import net.pterodactylus.sone.test.whenever
import net.pterodactylus.sone.utils.Pagination
import net.pterodactylus.sone.test.mock
import net.pterodactylus.sone.test.whenever
import net.pterodactylus.sone.utils.Pagination
+import net.pterodactylus.sone.web.baseInjector
+import net.pterodactylus.sone.web.page.*
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.emptyIterable
import org.hamcrest.Matchers.equalTo
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.emptyIterable
import org.hamcrest.Matchers.equalTo
+import org.hamcrest.Matchers.notNullValue
import org.junit.Before
import org.junit.Test
import org.mockito.ArgumentMatchers
import org.junit.Before
import org.junit.Test
import org.mockito.ArgumentMatchers
@@
-38,7
+42,7
@@
class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template,
@Test
fun `page returns correct title`() {
whenever(l10n.getString("Page.Index.Title")).thenReturn("index page title")
@Test
fun `page returns correct title`() {
whenever(l10n.getString("Page.Index.Title")).thenReturn("index page title")
- assertThat(page.getPageTitle(
freenet
Request), equalTo("index page title"))
+ assertThat(page.getPageTitle(
sone
Request), equalTo("index page title"))
}
@Before
}
@Before
@@
-134,7
+138,7
@@
class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template,
fun `index page sets page correctly`() {
val posts = listOf(createPost(3000), createPost(2000), createPost(1000))
whenever(currentSone.posts).thenReturn(posts)
fun `index page sets page correctly`() {
val posts = listOf(createPost(3000), createPost(2000), createPost(1000))
whenever(currentSone.posts).thenReturn(posts)
- core.preferences.
p
ostsPerPage = 1
+ core.preferences.
newP
ostsPerPage = 1
addHttpRequestParameter("page", "2")
page.processTemplate(freenetRequest, templateContext)
@Suppress("UNCHECKED_CAST")
addHttpRequestParameter("page", "2")
page.processTemplate(freenetRequest, templateContext)
@Suppress("UNCHECKED_CAST")
@@
-143,7
+147,7
@@
class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template,
@Test
fun `index page without posts sets correct pagination`() {
@Test
fun `index page without posts sets correct pagination`() {
- core.preferences.
p
ostsPerPage = 1
+ core.preferences.
newP
ostsPerPage = 1
page.processTemplate(freenetRequest, templateContext)
@Suppress("UNCHECKED_CAST")
(templateContext["pagination"] as Pagination<Post>).let { pagination ->
page.processTemplate(freenetRequest, templateContext)
@Suppress("UNCHECKED_CAST")
(templateContext["pagination"] as Pagination<Post>).let { pagination ->
@@
-151,4
+155,14
@@
class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template,
}
}
}
}
+ @Test
+ fun `page can be created by dependency injection`() {
+ assertThat(baseInjector.getInstance<IndexPage>(), notNullValue())
+ }
+
+ @Test
+ fun `page is annotated with correct menuname`() {
+ assertThat(page.menuName, equalTo("Index"))
+ }
+
}
}