Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
benjstephenson committed Jan 4, 2017
1 parent c275230 commit 23d2bc6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 4 additions & 4 deletions test/controllers/forms/AssistanceFormSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ class AssistanceFormSpec extends BaseSpec {
trait Fixture {

val noDisabilities = {
val data = Data("No", Some(List("")), None, Some("No"), "No", None, None, None, None)
val data = Data("No", Some(List("")), None, Some("No"), "No", None, None)

(data, AssistanceForm.form.fill(data))
}

val noAdjustments = {
val data = Data("Yes", Some(List("One of the disabilities")), None, None, "No", None, None, None, None)
val data = Data("Yes", Some(List("One of the disabilities")), None, None, "No", None, None)

(data, AssistanceForm.form.fill(data))
}

val fullForm: (Data, Form[Data]) = {
val data = Data("Yes", Some(List("One of the disabilities")), Some("some details"), None, "Yes", Some(List("other")), None, None, None)
val data = Data("Yes", Some(List("One of the disabilities")), Some("some details"), None, "Yes", Some(List("other")), None)

(data, AssistanceForm.form.fill(data))
}
Expand All @@ -79,7 +79,7 @@ class AssistanceFormSpec extends BaseSpec {
) = {

val data = Data(needsAssistance, typeOfdisability, detailsOfdisability, guaranteedInterview, needsAdjustment,
typeOfAdjustments, otherAdjustments, None, None)
typeOfAdjustments, otherAdjustments)

(data, AssistanceForm.form.fill(data))
}
Expand Down
17 changes: 12 additions & 5 deletions test/controllers/forms/SignUpFormSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ class SignUpFormSpec extends BaseSpec {
signUpForm.errors("password").head.messages must be(Seq(Messages("error.password")))
}

"throw an error if I haven't click on the I am eligible" in {
"throw an error if I haven't clicked on the I am eligible" in {
val (_, signUpForm) = SignupFormGenerator(agreeEligibleToApply = false).get
signUpForm.hasErrors must be(true)
signUpForm.errors.length must be(1)
signUpForm.errors("agreeEligibleToApply").head.messages must be(Seq(Messages("agree.eligible")))
}

"throw an error if I haven't click on the I agree" in {
"throw an error if I haven't clicked on the I agree" in {
val (_, signUpForm) = SignupFormGenerator(agree = false).get
signUpForm.hasErrors must be(true)
signUpForm.errors.length must be(1)
Expand All @@ -105,10 +105,14 @@ case class SignupFormGenerator(
password: String = "aA1234567",
confirm: String = "aA1234567",
agree: Boolean = true,
agreeEligibleToApply: Boolean = true
agreeEligibleToApply: Boolean = true,
campaignReferrer: Option[String] = Some("Google"),
campaignOther: Option[String] = Some("More Google")
) {

private val data = Data(firstName, lastName, email, confirmEmail, password, confirm, agree, agreeEligibleToApply)
private val data = Data(firstName, lastName, email, confirmEmail, password, confirm, agree, agreeEligibleToApply,
campaignReferrer, campaignOther
)

private val validFormData = Map(
"firstName" -> data.firstName,
Expand All @@ -118,7 +122,10 @@ case class SignupFormGenerator(
"password" -> data.password,
"confirmpwd" -> data.confirmpwd,
"agree" -> data.agree.toString,
"agreeEligibleToApply" -> data.agreeEligibleToApply.toString
"agreeEligibleToApply" -> data.agreeEligibleToApply.toString,
"campaignReferrer" -> data.campaignReferrer.getOrElse(""),
"campaignOther" -> data.campaignOther.getOrElse("")

)

private def signUpForm = Form(SignUpForm.form.mapping).bind(validFormData)
Expand Down

0 comments on commit 23d2bc6

Please sign in to comment.