/**
* Unit test for [IndexPage].
*/
-class IndexPageTest: WebPageTest({ webInterface, loaders, templateRenderer -> IndexPage(webInterface, loaders, templateRenderer, postVisibilityFilter) }) {
+class IndexPageTest : WebPageTest({ webInterface, loaders, templateRenderer -> IndexPage(webInterface, loaders, templateRenderer, postVisibilityFilter) }) {
companion object {
private val postVisibilityFilter = mock<PostVisibilityFilter>()
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("index.html"))
+ assertThat(page.path, equalTo("index.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
- whenever(l10n.getString("Page.Index.Title")).thenReturn("index page title")
- assertThat(page.getPageTitle(soneRequest), equalTo("index page title"))
+ addTranslation("Page.Index.Title", "index page title")
+ assertThat(page.getPageTitle(soneRequest), equalTo("index page title"))
}
@Before
fun setupPostVisibilityFilter() {
- whenever(postVisibilityFilter.isVisible(ArgumentMatchers.eq(currentSone))).thenReturn(Predicate<Post> { true })
+ whenever(postVisibilityFilter.isVisible(ArgumentMatchers.eq(currentSone))).thenReturn { true }
}
@Before
val followedPosts = listOf(createPost(2500, true), createPost(1500))
whenever(followedSone.posts).thenReturn(followedPosts)
whenever(currentSone.friends).thenReturn(listOf("followed1", "followed2"))
- whenever(postVisibilityFilter.isVisible(ArgumentMatchers.eq(currentSone))).thenReturn(Predicate<Post> { (it?.time ?: 10000) < 2500 })
+ whenever(postVisibilityFilter.isVisible(ArgumentMatchers.eq(currentSone))).thenReturn { (it?.time ?: 10000) < 2500 }
addSone("followed1", followedSone)
page.processTemplate(freenetRequest, templateContext)
@Suppress("UNCHECKED_CAST")
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<IndexPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<IndexPage>(), notNullValue())
}
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("Index"))
+ assertThat(page.menuName, equalTo("Index"))
}
@Test