Browse Source

fix specs

pull/833/head
Dushan Despotovic 3 years ago
parent
commit
8affed2ff0
  1. 8
      spec/components/check_answers_summary_list_card_component_spec.rb
  2. 37
      spec/fixtures/forms/2021_2022.json
  3. 4
      spec/models/form/subsection_spec.rb
  4. 2
      spec/models/form_handler_spec.rb
  5. 2
      spec/models/form_spec.rb

8
spec/components/check_answers_summary_list_card_component_spec.rb

@ -3,7 +3,7 @@ require "rails_helper"
RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do
context "when given a set of questions" do context "when given a set of questions" do
let(:user) { FactoryBot.build(:user) } let(:user) { FactoryBot.build(:user) }
let(:case_log) { FactoryBot.build(:case_log, :completed) } let(:case_log) { FactoryBot.build(:case_log, :completed, age2: 99) }
let(:subsection_id) { "household_characteristics" } let(:subsection_id) { "household_characteristics" }
let(:subsection) { case_log.form.get_subsection(subsection_id) } let(:subsection) { case_log.form.get_subsection(subsection_id) }
let(:questions) { subsection.applicable_questions(case_log) } let(:questions) { subsection.applicable_questions(case_log) }
@ -16,12 +16,12 @@ RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do
it "applicable questions doesn't return questions that are hidden in check answers" do it "applicable questions doesn't return questions that are hidden in check answers" do
summary_list = described_class.new(questions:, case_log:, user:) summary_list = described_class.new(questions:, case_log:, user:)
expect(summary_list.applicable_questions.map(&:id).include?("retirement_value_check")).to eq(false) expect(summary_list.applicable_questions.map(&:id).include?("retirement_value_check")).to eq(false)
end end
it "has the correct answer label for a question" do it "has the correct answer label for a question" do
summary_list = described_class.new(questions:, case_log:, user:) summary_list = described_class.new(questions:, case_log:, user:)
sex1_question = questions[2] sex1_question = questions[2]
expect(summary_list.get_answer_label(sex1_question)).to eq("Female") expect(summary_list.get_answer_label(sex1_question)).to eq("Female")
end end
end end
end end

37
spec/fixtures/forms/2021_2022.json vendored

@ -168,20 +168,6 @@
"step": 1, "step": 1,
"width": 2 "width": 2
}, },
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
},
"sex2": { "sex2": {
"check_answers_card_number": 2, "check_answers_card_number": 2,
"check_answer_label": "Person 2’s gender identity", "check_answer_label": "Person 2’s gender identity",
@ -204,6 +190,29 @@
} }
} }
}, },
"retirement_value_check": {
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"header": "Are you sure this person is retired?",
"type": "radio",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
}
},
"depends_on": [
{
"age2": { "operator": ">", "operand": 50 }
}
]
},
"person_2_working_situation": { "person_2_working_situation": {
"header": "", "header": "",
"description": "", "description": "",

4
spec/models/form/subsection_spec.rb

@ -25,12 +25,12 @@ RSpec.describe Form::Subsection, type: :model do
end end
it "has pages" do it "has pages" do
expected_pages = %w[tenant_code_test person_1_age person_1_gender person_1_working_situation household_number_of_members person_2_working_situation propcode] expected_pages = %w[tenant_code_test person_1_age person_1_gender person_1_working_situation household_number_of_members retirement_value_check person_2_working_situation propcode]
expect(subsection.pages.map(&:id)).to eq(expected_pages) expect(subsection.pages.map(&:id)).to eq(expected_pages)
end end
it "has questions" do it "has questions" do
expected_questions = %w[tenancycode age1 sex1 ecstat1 hhmemb relat2 age2 sex2 ecstat2 propcode] expected_questions = %w[tenancycode age1 sex1 ecstat1 hhmemb relat2 age2 sex2 retirement_value_check ecstat2 propcode]
expect(subsection.questions.map(&:id)).to eq(expected_questions) expect(subsection.questions.map(&:id)).to eq(expected_questions)
end end

2
spec/models/form_handler_spec.rb

@ -17,7 +17,7 @@ RSpec.describe FormHandler do
form_handler = described_class.instance form_handler = described_class.instance
form = form_handler.get_form(test_form_name) form = form_handler.get_form(test_form_name)
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(44) expect(form.pages.count).to eq(45)
end end
end end

2
spec/models/form_spec.rb

@ -178,7 +178,7 @@ RSpec.describe Form, type: :model do
describe "invalidated_page_questions" do describe "invalidated_page_questions" do
let(:case_log) { FactoryBot.create(:case_log, :in_progress, needstype: 1) } let(:case_log) { FactoryBot.create(:case_log, :in_progress, needstype: 1) }
let(:expected_invalid) { %w[scheme_id condition_effects cbl conditional_question_no_second_question net_income_value_check dependent_question offered layear declaration] } let(:expected_invalid) { %w[scheme_id retirement_value_check condition_effects cbl conditional_question_no_second_question net_income_value_check dependent_question offered layear declaration] }
context "when dependencies are not met" do context "when dependencies are not met" do
it "returns an array of question keys whose pages conditions are not met" do it "returns an array of question keys whose pages conditions are not met" do

Loading…
Cancel
Save