<commit_before>/*
 * Copyright 2017 HM Revenue & Customs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package iht.views.registration.deceased

import iht.forms.registration.DeceasedForms._
import iht.models.DeceasedDetails
import iht.views.html.registration.deceased.deceased_permanent_home
import iht.views.registration.RegistrationPageBehaviour
import play.api.data.Form
import play.api.i18n.Messages
import play.api.mvc.Call
import play.twirl.api.HtmlFormat.Appendable

class DeceasedPermanentHomeViewTest extends RegistrationPageBehaviour[DeceasedDetails] {
  override def pageTitle = Messages("page.iht.registration.deceasedPermanentHome.title")

  override def browserTitle = Messages("page.iht.registration.deceasedPermanentHome.browserTitle")

  override def fixture() = new {
    implicit val request = createFakeRequest()
    val form = deceasedPermanentHomeForm
    val func: Form[DeceasedDetails] => Appendable = form => deceased_permanent_home(form, Call("", ""))
    val view = func(form).toString
    val doc = asDocument(view)
  }

  "Deceased Permanent Home View" must {
    behave like registrationPageWithErrorSummaryBox()

    "have a fieldset with the Id 'country'" in {
      fixture().doc.getElementsByTag("fieldset").first.id shouldBe "country"
    }

    "have a radio button for england or wales" in {
      radioButtonShouldBeCorrect(fixture().doc, "iht.countries.englandOrWales", "domicile-england_or_wales")
    }

    "have a radio button for scotland" in {
      radioButtonShouldBeCorrect(fixture().doc, "iht.countries.scotland", "domicile-scotland")
    }

    "have a radio button for northern ireland" in {
      radioButtonShouldBeCorrect(fixture().doc, "iht.countries.northernIreland", "domicile-northern_ireland")
    }

    "have a radio button for other" in {
      radioButtonShouldBeCorrect(fixture().doc, "page.iht.registration.deceasedDetails.domicile.other.label", "domicile-other")
    }
  }
}
<commit_msg>IHT-4114 Code review comment<commit_after>/*
 * Copyright 2017 HM Revenue & Customs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package iht.views.registration.deceased

import iht.forms.registration.DeceasedForms._
import iht.models.DeceasedDetails
import iht.views.html.registration.deceased.deceased_permanent_home
import iht.views.registration.RegistrationPageBehaviour
import play.api.data.Form
import play.api.i18n.Messages
import play.api.mvc.Call
import play.twirl.api.HtmlFormat.Appendable

class DeceasedPermanentHomeViewTest extends RegistrationPageBehaviour[DeceasedDetails] {
  override def pageTitle = Messages("page.iht.registration.deceasedPermanentHome.title")

  override def browserTitle = Messages("page.iht.registration.deceasedPermanentHome.browserTitle")

  override def fixture() = new {
    implicit val request = createFakeRequest()
    val form = deceasedPermanentHomeForm
    val func: Form[DeceasedDetails] => Appendable = form => deceased_permanent_home(form, Call("", ""))
    val view = func(form).toString
    val doc = asDocument(view)
  }

  "Deceased Permanent Home View" must {
    behave like registrationPageWithErrorSummaryBox()

    "have a fieldset with the Id 'country'" in {
      fixture().doc.getElementsByTag("fieldset").first.id shouldBe "country"
    }
  }

  "radio buttons" must {
    "include england or wales" in {
      radioButtonShouldBeCorrect(fixture().doc, "iht.countries.englandOrWales", "domicile-england_or_wales")
    }

    "include scotland" in {
      radioButtonShouldBeCorrect(fixture().doc, "iht.countries.scotland", "domicile-scotland")
    }

    "include northern ireland" in {
      radioButtonShouldBeCorrect(fixture().doc, "iht.countries.northernIreland", "domicile-northern_ireland")
    }

    "include other" in {
      radioButtonShouldBeCorrect(fixture().doc, "page.iht.registration.deceasedDetails.domicile.other.label", "domicile-other")
    }
  }
}

{'fraction_non_alphanumeric': 0.09491869918699188, 'fraction_numerical': 0.004878048780487805, 'mean_word_length': 4.431567328918322, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4671894', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1438, 'n_words': 390}