Browse Source

CLDC-2439: tests added, copy moved to en.yml

pull/1718/head
Aaron Spencer 3 years ago
parent
commit
cc4b661898
  1. 2
      app/models/form/lettings/questions/max_rent_value_check.rb
  2. 5
      app/models/form/lettings/questions/min_rent_value_check.rb
  3. 44
      spec/models/form/lettings/questions/max_rent_value_check_spec.rb
  4. 10
      spec/models/form/lettings/questions/min_rent_value_check_spec.rb

2
app/models/form/lettings/questions/max_rent_value_check.rb

@ -5,7 +5,7 @@ class Form::Lettings::Questions::MaxRentValueCheck < ::Form::Question
@check_answer_label = "Total rent confirmation"
@header = "Are you sure this is correct?"
@type = "interruption_screen"
@hint_text = "This is higher than we would expect. Check:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>"
@hint_text = I18n.t("soft_validations.rent.hint_text", higher_or_lower: "higher")
@check_answers_card_number = check_answers_card_number
@answer_options = ANSWER_OPTIONS
@hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] }

5
app/models/form/lettings/questions/min_rent_value_check.rb

@ -5,14 +5,11 @@ class Form::Lettings::Questions::MinRentValueCheck < ::Form::Question
@check_answer_label = "Total rent confirmation"
@header = "Are you sure this is correct?"
@type = "interruption_screen"
@hint_text = I18n.t("soft_validations.rent.soft_min_hint_text")
# @hint_text = "This is lower than we would expect. Check:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>"
@hint_text = I18n.t("soft_validations.rent.hint_text", higher_or_lower: "lower")
@check_answers_card_number = check_answers_card_number
@answer_options = ANSWER_OPTIONS
@hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] }
end
ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze
end

44
spec/models/form/lettings/questions/max_rent_value_check_spec.rb

@ -0,0 +1,44 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::MaxRentValueCheck, type: :model do
subject(:question) { described_class.new(nil, question_definition, page, check_answers_card_number:) }
let(:question_definition) { nil }
let(:check_answers_card_number) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("rent_value_check")
end
it "has the correct header" do
expect(question.header).to eq("Are you sure this is correct?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Total rent confirmation")
end
it "has the correct type" do
expect(question.type).to eq("interruption_screen")
end
it "has the correct hint" do
expect(question.hint_text).to eq("This is higher than we would expect. Check:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>")
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({ "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] })
end
end

10
spec/models/form/lettings/questions/min_rent_value_check_spec.rb

@ -1,6 +1,6 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::MaxRentValueCheck, type: :model do
RSpec.describe Form::Lettings::Questions::MinRentValueCheck, type: :model do
subject(:question) { described_class.new(nil, question_definition, page, check_answers_card_number:) }
let(:question_definition) { nil }
@ -28,14 +28,14 @@ RSpec.describe Form::Lettings::Questions::MaxRentValueCheck, type: :model do
end
it "has the correct hint" do
expect(question.hint_text).to eq("This is higher than we would expect. Check:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>")
expect(question.hint_text).to eq("This is lower than we would expect. Check:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>")
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do

Loading…
Cancel
Save