Browse Source

Add tests

pull/2780/head
Manny Dinssa 9 months ago
parent
commit
995edc384b
  1. 20
      spec/models/form/sales/subsections/household_situation_spec.rb
  2. 25
      spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb
  3. 14
      spec/models/form/sales/subsections/other_household_information_spec.rb

20
spec/models/form/sales/subsections/household_situation_spec.rb

@ -25,6 +25,14 @@ RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do
],
)
end
it "has the correct id" do
expect(household_characteristics.id).to eq("household_situation")
end
it "has the correct label" do
expect(household_characteristics.label).to eq("Household situation")
end
end
context "when the start year is 2025" do
@ -41,17 +49,9 @@ RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do
],
)
end
end
it "has the correct id" do
expect(household_characteristics.id).to eq("household_situation")
end
it "has the correct label" do
expect(household_characteristics.label).to eq("Household situation")
end
it "has correct depends on" do
expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }])
expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true, "is_staircase?" => false }])
end
end
end

25
spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb

@ -11,8 +11,16 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
expect(subsection.section).to eq(section)
end
it "has the correct id" do
expect(subsection.id).to eq("income_benefits_and_savings")
end
it "has the correct label" do
expect(subsection.label).to eq("Income, benefits and savings")
end
describe "pages" do
let(:section) { instance_double(Form::Sales::Sections::Household, form: instance_double(Form, start_date:)) }
let(:section) { instance_double(Form::Sales::Sections::Household, form: instance_double(Form, start_date:, start_year_2025_or_later?: false)) }
context "when 2022" do
let(:start_date) { Time.utc(2022, 2, 8) }
@ -83,18 +91,19 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
],
)
end
it "has correct depends on" do
expect(subsection.depends_on).to eq([{ "setup_completed?" => true }])
end
end
it "has the correct id" do
expect(subsection.id).to eq("income_benefits_and_savings")
end
it "has the correct label" do
expect(subsection.label).to eq("Income, benefits and savings")
end
context "when 2025" do
let(:start_date) { Time.utc(2025, 2, 8) }
let(:section) { instance_double(Form::Sales::Sections::Household, form: instance_double(Form, start_date:, start_year_2025_or_later?: true)) }
it "has correct depends on" do
expect(subsection.depends_on).to eq([{ "setup_completed?" => true }])
expect(subsection.depends_on).to eq([{ "setup_completed?" => true, "is_staircase?" => false }])
end
end
end

14
spec/models/form/sales/subsections/other_household_information_spec.rb

@ -5,7 +5,9 @@ RSpec.describe Form::Sales::Subsections::OtherHouseholdInformation, type: :model
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
context "when 2024" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2025_or_later?: false) }
let(:section) { instance_double(Form::Sales::Sections::Household, form:) }
it "has correct section" do
@ -38,3 +40,13 @@ RSpec.describe Form::Sales::Subsections::OtherHouseholdInformation, type: :model
expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }])
end
end
context "when 2025" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1), start_year_2025_or_later?: true) }
let(:section) { instance_double(Form::Sales::Sections::Household, form:) }
it "has correct depends on" do
expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true, "is_staircase?" => false }])
end
end
end

Loading…
Cancel
Save