Merge branch 'release-0.9.6'
[Sone.git] / src / test / java / net / pterodactylus / sone / web / ajax / GetTimesAjaxPageTest.java
1 package net.pterodactylus.sone.web.ajax;
2
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;
9
10 import net.pterodactylus.sone.web.WebInterface;
11 import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage.Time;
12
13 import org.junit.Test;
14 import org.mockito.Mockito;
15
16 /**
17  * Unit test for {@link GetTimesAjaxPage}.
18  *
19  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
20  */
21 public class GetTimesAjaxPageTest {
22
23         private final WebInterface webInterface = Mockito.mock(WebInterface.class, RETURNS_DEEP_STUBS);
24
25         @Test
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"));
30         }
31
32         @Test
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"));
37         }
38
39 }