Browse Source

feat: update tests

pull/1696/head
natdeanlewissoftwire 3 years ago
parent
commit
a954bcb617
  1. 4
      spec/helpers/question_view_helper_spec.rb
  2. 40
      spec/models/form/lettings/questions/address_line1_spec.rb
  3. 10
      spec/models/form/lettings/questions/county_spec.rb
  4. 10
      spec/models/form/lettings/questions/postcode_for_full_address_spec.rb
  5. 10
      spec/models/form/lettings/questions/town_or_city_spec.rb
  6. 44
      spec/models/form/sales/questions/address_line1_spec.rb
  7. 10
      spec/models/form/sales/questions/county_spec.rb
  8. 10
      spec/models/form/sales/questions/postcode_for_full_address_spec.rb
  9. 10
      spec/models/form/sales/questions/town_or_city_spec.rb
  10. 8
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

4
spec/helpers/question_view_helper_spec.rb

@ -53,6 +53,10 @@ RSpec.describe QuestionViewHelper do
def plain_label def plain_label
nil nil
end end
def hide_question_number_on_page
false
end
end end
end end

40
spec/models/form/lettings/questions/address_line1_spec.rb

@ -19,12 +19,16 @@ RSpec.describe Form::Lettings::Questions::AddressLine1, type: :model do
expect(question.header).to eq("Address line 1") expect(question.header).to eq("Address line 1")
end end
it "has the correct question_number" do it "has the correct error label" do
expect(question.question_number).to be_nil expect(question.error_label).to eq("Address line 1")
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Q12 - Address lines 1 and 2") expect(question.check_answer_label).to eq("Address lines 1 and 2")
end
it "has the correct question_number" do
expect(question.question_number).to eq(12)
end end
it "has the correct type" do it "has the correct type" do
@ -46,34 +50,4 @@ RSpec.describe Form::Lettings::Questions::AddressLine1, type: :model do
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to be_nil expect(question.check_answers_card_number).to be_nil
end end
describe "has the correct get_extra_check_answer_value" do
context "when la is not present" do
let(:log) { create(:lettings_log, la: nil) }
it "returns nil" do
expect(question.get_extra_check_answer_value(log)).to be_nil
end
end
context "when la is present but not inferred" do
let(:log) { create(:lettings_log, la: "E09000003", is_la_inferred: false) }
it "returns nil" do
expect(question.get_extra_check_answer_value(log)).to be_nil
end
end
context "when la is present and inferred" do
let(:log) { create(:lettings_log, la: "E09000003") }
before do
allow(log).to receive(:is_la_inferred?).and_return(true)
end
it "returns the la" do
expect(question.get_extra_check_answer_value(log)).to eq("Barnet")
end
end
end
end end

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

@ -20,7 +20,11 @@ RSpec.describe Form::Lettings::Questions::County, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Q12 - County") expect(question.check_answer_label).to eq("County")
end
it "has the correct question_number" do
expect(question.question_number).to eq(12)
end end
it "has the correct type" do it "has the correct type" do
@ -42,8 +46,4 @@ RSpec.describe Form::Lettings::Questions::County, type: :model do
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to be_nil expect(question.check_answers_card_number).to be_nil
end end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers?).to eq(true)
end
end end

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

@ -20,7 +20,11 @@ RSpec.describe Form::Lettings::Questions::PostcodeForFullAddress, type: :model d
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Q12 - Postcode") expect(question.check_answer_label).to eq("Postcode")
end
it "has the correct question_number" do
expect(question.question_number).to eq(12)
end end
it "has the correct type" do it "has the correct type" do
@ -55,8 +59,4 @@ RSpec.describe Form::Lettings::Questions::PostcodeForFullAddress, type: :model d
"value" => "Not known", "value" => "Not known",
}]) }])
end end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers?).to eq(true)
end
end end

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

@ -20,7 +20,11 @@ RSpec.describe Form::Lettings::Questions::TownOrCity, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Q12 - Town or city") expect(question.check_answer_label).to eq("Town or city")
end
it "has the correct question_number" do
expect(question.question_number).to eq(12)
end end
it "has the correct type" do it "has the correct type" do
@ -42,8 +46,4 @@ RSpec.describe Form::Lettings::Questions::TownOrCity, type: :model do
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to be_nil expect(question.check_answers_card_number).to be_nil
end end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers?).to eq(true)
end
end end

44
spec/models/form/sales/questions/address_line1_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Sales::Questions::AddressLine1, type: :model do
expect(question.page).to eq(page) expect(question.page).to eq(page)
end end
it "has the correct question_number" do
expect(question.question_number).to be_nil
end
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("address_line1") expect(question.id).to eq("address_line1")
end end
@ -23,8 +19,16 @@ RSpec.describe Form::Sales::Questions::AddressLine1, type: :model do
expect(question.header).to eq("Address line 1") expect(question.header).to eq("Address line 1")
end end
it "has the correct error label" do
expect(question.error_label).to eq("Address line 1")
end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Q15 - Address lines 1 and 2") expect(question.check_answer_label).to eq("Address lines 1 and 2")
end
it "has the correct question_number" do
expect(question.question_number).to eq(15)
end end
it "has the correct type" do it "has the correct type" do
@ -46,34 +50,4 @@ RSpec.describe Form::Sales::Questions::AddressLine1, type: :model do
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to be_nil expect(question.check_answers_card_number).to be_nil
end end
describe "has the correct get_extra_check_answer_value" do
context "when la is not present" do
let(:log) { create(:sales_log, la: nil) }
it "returns nil" do
expect(question.get_extra_check_answer_value(log)).to be_nil
end
end
context "when la is present but not inferred" do
let(:log) { create(:sales_log, la: "E09000003", is_la_inferred: false) }
it "returns nil" do
expect(question.get_extra_check_answer_value(log)).to be_nil
end
end
context "when la is present and inferred" do
let(:log) { create(:sales_log, la: "E09000003") }
before do
allow(log).to receive(:is_la_inferred?).and_return(true)
end
it "returns the la" do
expect(question.get_extra_check_answer_value(log)).to eq("Barnet")
end
end
end
end end

10
spec/models/form/sales/questions/county_spec.rb

@ -20,7 +20,11 @@ RSpec.describe Form::Sales::Questions::County, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Q15 - County") expect(question.check_answer_label).to eq("County")
end
it "has the correct question_number" do
expect(question.question_number).to eq(15)
end end
it "has the correct type" do it "has the correct type" do
@ -42,8 +46,4 @@ RSpec.describe Form::Sales::Questions::County, type: :model do
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to be_nil expect(question.check_answers_card_number).to be_nil
end end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers?).to eq(true)
end
end end

10
spec/models/form/sales/questions/postcode_for_full_address_spec.rb

@ -20,7 +20,11 @@ RSpec.describe Form::Sales::Questions::PostcodeForFullAddress, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Q15 - Postcode") expect(question.check_answer_label).to eq("Postcode")
end
it "has the correct question_number" do
expect(question.question_number).to eq(15)
end end
it "has the correct type" do it "has the correct type" do
@ -55,8 +59,4 @@ RSpec.describe Form::Sales::Questions::PostcodeForFullAddress, type: :model do
"value" => "Not known", "value" => "Not known",
}]) }])
end end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers?).to eq(true)
end
end end

10
spec/models/form/sales/questions/town_or_city_spec.rb

@ -20,7 +20,11 @@ RSpec.describe Form::Sales::Questions::TownOrCity, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Q15 - Town or city") expect(question.check_answer_label).to eq("Town or city")
end
it "has the correct question_number" do
expect(question.question_number).to eq(15)
end end
it "has the correct type" do it "has the correct type" do
@ -42,8 +46,4 @@ RSpec.describe Form::Sales::Questions::TownOrCity, type: :model do
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to be_nil expect(question.check_answers_card_number).to be_nil
end end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers?).to eq(true)
end
end end

8
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -340,8 +340,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "fetches the question's check_answer_label if it exists, otherwise it gets the question's header" do it "fetches the question's check_answer_label if it exists, otherwise it gets the question's header" do
parser.valid? parser.valid?
expect(parser.errors[:field_19]).to eql(["You must answer q12 - address lines 1 and 2"]) expect(parser.errors[:field_19]).to eql(["You must answer address line 1"])
expect(parser.errors[:field_21]).to eql(["You must answer q12 - town or city"]) expect(parser.errors[:field_21]).to eql(["You must answer town or city"])
end end
end end
end end
@ -937,8 +937,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds appropriate errors" do it "adds appropriate errors" do
expect(parser.errors[:field_18]).to eql(["You must answer UPRN"]) expect(parser.errors[:field_18]).to eql(["You must answer UPRN"])
expect(parser.errors[:field_19]).to eql(["You must answer q12 - address lines 1 and 2"]) expect(parser.errors[:field_19]).to eql(["You must answer address line 1"])
expect(parser.errors[:field_21]).to eql(["You must answer q12 - town or city"]) expect(parser.errors[:field_21]).to eql(["You must answer town or city"])
end end
end end

Loading…
Cancel
Save