package controllers.disposal_of_vehicle

import helpers.webbrowser.TestGlobal
import helpers.{UnitSpec, WithApplication}
import pages.disposal_of_vehicle._
import play.api.test.{FakeApplication, FakeRequest}
import play.api.test.Helpers._

final class BeforeYouStartUnitSpec extends UnitSpec {
  "present" should {
    "display the page" in new WithApplication {
      val result = beforeYouStart.present(FakeRequest())
      status(result) should equal(OK)
    }

    "display expected progress bar" in new WithApplication {
      val result = beforeYouStart.present(FakeRequest())
      contentAsString(result) should include("Step 1 of 6")
    }

    "display prototype message when config set to true" in new WithApplication {
      val result = beforeYouStart.present(FakeRequest())
      contentAsString(result) should include("""<div class="prototype">""")
    }
  }

  "submit" should {
    "redirect to next page after the button is clicked" in new WithApplication {
      val result = beforeYouStart.submit(FakeRequest())
      whenReady(result) {
        r => r.header.headers.get(LOCATION) should equal(Some(SetupTradeDetailsPage.address))
      }
    }
  }

  private val beforeYouStart = injector.getInstance(classOf[BeforeYouStart])
}

package controllers.disposal_of_vehicle

import common.ClientSideSessionFactory
import helpers.webbrowser.TestGlobal
import helpers.{UnitSpec, WithApplication}
import pages.disposal_of_vehicle._
import play.api.test.{FakeApplication, FakeRequest}
import play.api.test.Helpers._
import utils.helpers.Config
import org.mockito.Mockito._

final class BeforeYouStartUnitSpec extends UnitSpec {
  "present" should {
    "display the page" in new WithApplication {
      val result = beforeYouStart.present(FakeRequest())
      status(result) should equal(OK)
    }

    "display expected progress bar" in new WithApplication {
      val result = beforeYouStart.present(FakeRequest())
      contentAsString(result) should include("Step 1 of 6")
    }

    "display prototype message when config set to true" in new WithApplication {
      val result = beforeYouStart.present(FakeRequest())
      contentAsString(result) should include("""<div class="prototype">""")
    }

    "not display prototype message when config set to false" in new WithApplication {
      val request = FakeRequest()
      implicit val clientSideSessionFactory = injector.getInstance(classOf[ClientSideSessionFactory])
      implicit val config: Config = mock[Config]
      when(config.isPrototypeBannerVisible).thenReturn(false)
      val beforeYouStartPrototypeNotVisible = new BeforeYouStart()

      val result = beforeYouStartPrototypeNotVisible.present(request)
      contentAsString(result) should not include """<div class="prototype">"""
    }
  }

  "submit" should {
    "redirect to next page after the button is clicked" in new WithApplication {
      val result = beforeYouStart.submit(FakeRequest())
      whenReady(result) {
        r => r.header.headers.get(LOCATION) should equal(Some(SetupTradeDetailsPage.address))
      }
    }
  }

  private val beforeYouStart = injector.getInstance(classOf[BeforeYouStart])
}

Test for display prototype and progress bar
Test for display prototype and progress bar


Former-commit-id: 4311a9d97a744ca6ea7e40238f7cd1c9e81d0a63