1 package net.pterodactylus.sone.web.ajax;
3 import static java.lang.System.currentTimeMillis;
4 import static net.pterodactylus.sone.web.ajax.GetTimesAjaxPage.getTime;
5 import static org.hamcrest.MatcherAssert.assertThat;
6 import static org.hamcrest.Matchers.is;
7 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
8 import static org.mockito.Mockito.when;
10 import net.pterodactylus.sone.web.WebInterface;
11 import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage.Time;
13 import org.junit.Test;
14 import org.mockito.Mockito;
17 * Unit test for {@link GetTimesAjaxPage}.
19 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
21 public class GetTimesAjaxPageTest {
23 private final WebInterface webInterface = Mockito.mock(WebInterface.class, RETURNS_DEEP_STUBS);
26 public void timestampInTheFutureIsTranslatedCorrectly() {
27 when(webInterface.getL10n().getString("View.Time.InTheFuture")).thenReturn("in the future");
28 Time time = getTime(webInterface, currentTimeMillis() + 100);
29 assertThat(time.getText(), is("in the future"));
33 public void timestampAFewSecondsAgoIsTranslatedCorrectly() {
34 when(webInterface.getL10n().getString("View.Time.AFewSecondsAgo")).thenReturn("a few seconds ago");
35 Time time = getTime(webInterface, currentTimeMillis() - 1000);
36 assertThat(time.getText(), is("a few seconds ago"));