Browse Source

CLDC-4166: test updates

pull/3194/head
Nat Dean-Lewis 3 weeks ago
parent
commit
eda0b93060
  1. 104
      spec/models/form/sales/pages/person_known_spec.rb
  2. 49
      spec/models/form/sales/questions/number_of_others_in_property_spec.rb

104
spec/models/form/sales/pages/person_known_spec.rb

@ -3,11 +3,13 @@ require "rails_helper"
RSpec.describe Form::Sales::Pages::PersonKnown, type: :model do RSpec.describe Form::Sales::Pages::PersonKnown, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) }
context "without joint purchase" do let(:page_id) { "person_2_known" }
let(:page_id) { "person_2_known" } let(:page_definition) { nil }
let(:page_definition) { nil } let(:person_index) { 2 }
let(:subsection) { instance_double(Form::Subsection) }
let(:person_index) { 2 } context "with 2024 form" do
let(:form) { Form.new(nil, 2024, [], "sales") }
let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
@ -153,4 +155,96 @@ RSpec.describe Form::Sales::Pages::PersonKnown, type: :model do
end end
end end
end end
context "with 2026 form" do
let(:form) { Form.new(nil, 2026, [], "sales") }
let(:subsection) { instance_double(Form::Subsection, form:) }
context "with person 2" do
let(:page_id) { "person_2_known" }
let(:person_index) { 2 }
it "has correct depends_on" do
expect(page.depends_on).to eq([{
"not_joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 2,
},
}])
end
end
context "with person 3" do
let(:page_id) { "person_3_known" }
let(:person_index) { 3 }
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"not_joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 3,
},
},
{
"joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 3,
},
},
])
end
end
context "with person 4" do
let(:page_id) { "person_4_known" }
let(:person_index) { 4 }
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"not_joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 4,
},
},
{
"joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 4,
},
},
])
end
end
context "with person 5" do
let(:page_id) { "person_5_known" }
let(:person_index) { 5 }
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"not_joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 5,
},
},
{
"joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 5,
},
},
])
end
end
end
end end

49
spec/models/form/sales/questions/number_of_others_in_property_spec.rb

@ -5,30 +5,45 @@ RSpec.describe Form::Sales::Questions::NumberOfOthersInProperty, type: :model do
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) }
let(:joint_purchase) { true } let(:joint_purchase) { true }
it "has correct page" do context "with 2023 form" do
expect(question.page).to be(page) let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2026_or_later?: false))) }
end
it "has the correct id" do it "has correct page" do
expect(question.id).to eq("hholdcount") expect(question.page).to be(page)
end end
it "has the correct type" do it "has the correct id" do
expect(question.type).to eq("numeric") expect(question.id).to eq("hholdcount")
end end
it "is not marked as derived" do it "has the correct type" do
expect(question.derived?(nil)).to be false expect(question.type).to eq("numeric")
end end
it "has the correct min" do it "is not marked as derived" do
expect(question.min).to be 0 expect(question.derived?(nil)).to be false
end
it "has the correct min" do
expect(question.min).to be 0
end
it "has the correct max" do
expect(question.max).to be 15
end
end end
it "has the correct max" do context "with 2026 form" do
expect(question.max).to be 15 let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2026, 4, 1), start_year_2026_or_later?: true))) }
it "has the correct min" do
expect(question.min).to be 1
end
it "has the correct max" do
expect(question.max).to be 15
end
end end
end end

Loading…
Cancel
Save