1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.test.deepMock
4 import net.pterodactylus.sone.test.whenever
5 import net.pterodactylus.sone.web.WebInterface
6 import org.hamcrest.MatcherAssert.assertThat
7 import org.hamcrest.Matchers.equalTo
9 import java.lang.System.currentTimeMillis
12 * Unit test for [GetTimesAjaxPage].
14 class GetTimesAjaxPageTest {
16 private val webInterface = deepMock<WebInterface>()
19 fun timestampInTheFutureIsTranslatedCorrectly() {
20 whenever(webInterface.l10n.getString("View.Time.InTheFuture")).thenReturn("in the future")
21 val time = GetTimesAjaxPage.getTime(webInterface, currentTimeMillis() + 1000)
22 assertThat(time.text, equalTo("in the future"))
26 fun timestampAFewSecondsAgoIsTranslatedCorrectly() {
27 whenever(webInterface.l10n.getString("View.Time.AFewSecondsAgo")).thenReturn("a few seconds ago")
28 val time = GetTimesAjaxPage.getTime(webInterface, currentTimeMillis() - 1000)
29 assertThat(time.text, equalTo("a few seconds ago"))