Browse Source

Add tests where there is logic on page/question to decide copy key

pull/2672/head
Rachael Booth 8 months ago
parent
commit
9a4f2bc52d
  1. 16
      spec/models/form/sales/pages/buyer_interview_spec.rb
  2. 22
      spec/models/form/sales/pages/privacy_notice_spec.rb
  3. 16
      spec/models/form/sales/questions/buyer_interview_spec.rb
  4. 16
      spec/models/form/sales/questions/privacy_notice_spec.rb

16
spec/models/form/sales/pages/buyer_interview_spec.rb

@ -22,4 +22,20 @@ RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do
it "has the correct description" do
expect(page.description).to be_nil
end
context "when there are joint buyers" do
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) }
it "has the expected copy_key" do
expect(page.copy_key).to eq("sales.setup.noint.joint_purchase")
end
end
context "when there is a single buyer" do
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) }
it "has the expected copy_key" do
expect(page.copy_key).to eq("sales.setup.noint.not_joint_purchase")
end
end
end

22
spec/models/form/sales/pages/privacy_notice_spec.rb

@ -29,21 +29,27 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do
expect(page.description).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }, { "jointpur" => nil }])
end
context "with joint purchase" do
context "when there are joint buyers" do
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) }
let(:page_id) { "privacy_notice_joint_purchase" }
it "has the expected copy_key" do
expect(page.copy_key).to eq("sales.setup.privacynotice.joint_purchase")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "joint_purchase?" => true }])
end
end
context "when there is a single buyer" do
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) }
it "has the expected copy_key" do
expect(page.copy_key).to eq("sales.setup.privacynotice.not_joint_purchase")
end
it "has the correct id" do
expect(page.id).to eq("privacy_notice_joint_purchase")
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }, { "jointpur" => nil }])
end
end
end

16
spec/models/form/sales/questions/buyer_interview_spec.rb

@ -29,4 +29,20 @@ RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do
"1" => { "value" => "No" },
})
end
context "when there are joint buyers" do
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) }
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.setup.noint.joint_purchase")
end
end
context "when there is a single buyer" do
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: false) }
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.setup.noint.not_joint_purchase")
end
end
end

16
spec/models/form/sales/questions/privacy_notice_spec.rb

@ -31,6 +31,22 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
expect(question.derived?(nil)).to be false
end
context "when there are joint buyers" do
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) }
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.setup.privacynotice.joint_purchase")
end
end
context "when there is a single buyer" do
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: false) }
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.setup.privacynotice.not_joint_purchase")
end
end
context "when the form year is before 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)

Loading…
Cancel
Save