Browse Source

CLDC-4166: test updates

pull/3194/head
Nat Dean-Lewis 2 months ago
parent
commit
eda0b93060
  1. 98
      spec/models/form/sales/pages/person_known_spec.rb
  2. 17
      spec/models/form/sales/questions/number_of_others_in_property_spec.rb

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

@ -3,12 +3,14 @@ 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(:subsection) { instance_double(Form::Subsection) }
let(:person_index) { 2 } 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)
end end
@ -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

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

@ -5,9 +5,11 @@ 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 }
context "with 2023 form" do
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))) }
it "has correct page" do it "has correct page" do
expect(question.page).to be(page) expect(question.page).to be(page)
end end
@ -31,4 +33,17 @@ RSpec.describe Form::Sales::Questions::NumberOfOthersInProperty, type: :model do
it "has the correct max" do it "has the correct max" do
expect(question.max).to be 15 expect(question.max).to be 15
end end
end
context "with 2026 form" do
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

Loading…
Cancel
Save