🔀 Merge branch 'release/v82'
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / ajax / GetTranslationAjaxPageTest.kt
1 package net.pterodactylus.sone.web.ajax
2
3 import net.pterodactylus.sone.test.getInstance
4 import net.pterodactylus.sone.web.baseInjector
5 import org.hamcrest.MatcherAssert.assertThat
6 import org.hamcrest.Matchers.equalTo
7 import org.hamcrest.Matchers.notNullValue
8 import org.junit.Test
9
10 /**
11  * Unit test for [GetTranslationAjaxPage].
12  */
13 class GetTranslationAjaxPageTest : JsonPageTest("getTranslation.ajax", requiresLogin = false, needsFormPassword = false, pageSupplier = ::GetTranslationAjaxPage) {
14
15         @Test
16         fun `translation is returned correctly`() {
17                 addTranslation("foo", "bar")
18                 addRequestParameter("key", "foo")
19                 assertThatJsonIsSuccessful()
20                 assertThat(json["value"]?.asText(), equalTo("bar"))
21         }
22
23         @Test
24         fun `page can be created by dependency injection`() {
25             assertThat(baseInjector.getInstance<GetTranslationAjaxPage>(), notNullValue())
26         }
27
28 }