aboutsummaryrefslogtreecommitdiff
path: root/test/controllers/HomeControllerSpec.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/controllers/HomeControllerSpec.scala')
-rw-r--r--test/controllers/HomeControllerSpec.scala45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/controllers/HomeControllerSpec.scala b/test/controllers/HomeControllerSpec.scala
new file mode 100644
index 0000000..836e3ef
--- /dev/null
+++ b/test/controllers/HomeControllerSpec.scala
@@ -0,0 +1,45 @@
+package controllers
+
+import org.scalatestplus.play._
+import play.api.test._
+import play.api.test.Helpers._
+
+/**
+ * Add your spec here.
+ * You can mock out a whole application including requests, plugins etc.
+ *
+ * For more information, see https://www.playframework.com/documentation/latest/ScalaTestingWithScalaTest
+ */
+class HomeControllerSpec extends PlaySpec with OneAppPerTest {
+
+ "HomeController GET" should {
+
+ "render the index page from a new instance of controller" in {
+ val controller = new HomeController
+ val home = controller.index().apply(FakeRequest())
+
+ status(home) mustBe OK
+ contentType(home) mustBe Some("text/html")
+ contentAsString(home) must include ("Welcome to Play")
+ }
+
+ "render the index page from the application" in {
+ val controller = app.injector.instanceOf[HomeController]
+ val home = controller.index().apply(FakeRequest())
+
+ status(home) mustBe OK
+ contentType(home) mustBe Some("text/html")
+ contentAsString(home) must include ("Welcome to Play")
+ }
+
+ "render the index page from the router" in {
+ // Need to specify Host header to get through AllowedHostsFilter
+ val request = FakeRequest(GET, "/").withHeaders("Host" -> "localhost")
+ val home = route(app, request).get
+
+ status(home) mustBe OK
+ contentType(home) mustBe Some("text/html")
+ contentAsString(home) must include ("Welcome to Play")
+ }
+ }
+}