1
0
mirror of https://github.com/pcvolkmer/onco-analytics-monitor.git synced 2025-04-19 11:06:52 +00:00

test: add test for HomeController

This commit is contained in:
Paul-Christian Volkmer 2024-08-12 12:07:35 +02:00
parent cd15449c2b
commit 010985d096

View File

@ -0,0 +1,41 @@
package dev.pcvolkmer.oncoanalytics.monitor.web
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest
import org.springframework.http.MediaType
import org.springframework.test.web.reactive.server.WebTestClient
@WebFluxTest(controllers = [HomeController::class])
class HomeControllerTest {
private lateinit var webClient: WebTestClient
@BeforeEach
fun setup(
@Autowired webClient: WebTestClient,
) {
this.webClient = webClient
}
@Test
fun shouldGetStartPage() {
webClient
.get().uri("/")
.exchange()
.expectAll(
{ spec -> spec.expectStatus().isOk },
{ spec -> spec.expectHeader().contentType(MediaType.TEXT_HTML) },
{ spec ->
spec.expectBody()
.consumeWith {
assertThat(it.responseBody).isNotNull()
assertThat(String(it.responseBody!!)).contains("<h1>onco-analytics-monitor</h1>")
}
}
)
}
}