6 changed files with 416 additions and 1 deletions
@ -0,0 +1,38 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1YesNo, type: :model do |
||||||
|
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||||
|
|
||||||
|
let(:page_id) { nil } |
||||||
|
let(:page_definition) { nil } |
||||||
|
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1))) } |
||||||
|
|
||||||
|
it "has correct subsection" do |
||||||
|
expect(page.subsection).to eq(subsection) |
||||||
|
end |
||||||
|
|
||||||
|
it "has correct questions" do |
||||||
|
expect(page.questions.map(&:id)).to eq(%w[relat2]) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct id" do |
||||||
|
expect(page.id).to eq("buyer_2_relationship_to_buyer_1") |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct description" do |
||||||
|
expect(page.description).to be_nil |
||||||
|
end |
||||||
|
|
||||||
|
it "has correct depends_on" do |
||||||
|
expect(page.depends_on).to eq([ |
||||||
|
{ |
||||||
|
"joint_purchase?" => true, |
||||||
|
"buyer_has_seen_privacy_notice?" => true, |
||||||
|
}, |
||||||
|
{ |
||||||
|
"joint_purchase?" => true, |
||||||
|
"buyer_not_interviewed?" => true, |
||||||
|
}, |
||||||
|
]) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,87 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe Form::Sales::Pages::PersonRelationshipToBuyer1YesNo, type: :model do |
||||||
|
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } |
||||||
|
|
||||||
|
let(:page_definition) { nil } |
||||||
|
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1))) } |
||||||
|
let(:person_index) { 1 } |
||||||
|
|
||||||
|
let(:page_id) { "person_1_relationship_to_buyer_1" } |
||||||
|
|
||||||
|
it "has correct subsection" do |
||||||
|
expect(page.subsection).to eq(subsection) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct description" do |
||||||
|
expect(page.description).to be_nil |
||||||
|
end |
||||||
|
|
||||||
|
context "with person 2" do |
||||||
|
let(:person_index) { 2 } |
||||||
|
let(:page_id) { "person_2_relationship_to_buyer_1" } |
||||||
|
|
||||||
|
it "has correct questions" do |
||||||
|
expect(page.questions.map(&:id)).to eq(%w[relat2]) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct id" do |
||||||
|
expect(page.id).to eq("person_2_relationship_to_buyer_1") |
||||||
|
end |
||||||
|
|
||||||
|
it "has correct depends_on" do |
||||||
|
expect(page.depends_on).to eq([{ "details_known_2" => 1 }]) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context "with person 3" do |
||||||
|
let(:person_index) { 3 } |
||||||
|
let(:page_id) { "person_3_relationship_to_buyer_1" } |
||||||
|
|
||||||
|
it "has correct questions" do |
||||||
|
expect(page.questions.map(&:id)).to eq(%w[relat3]) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct id" do |
||||||
|
expect(page.id).to eq("person_3_relationship_to_buyer_1") |
||||||
|
end |
||||||
|
|
||||||
|
it "has correct depends_on" do |
||||||
|
expect(page.depends_on).to eq([{ "details_known_3" => 1 }]) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context "with person 4" do |
||||||
|
let(:person_index) { 4 } |
||||||
|
let(:page_id) { "person_4_relationship_to_buyer_1" } |
||||||
|
|
||||||
|
it "has correct questions" do |
||||||
|
expect(page.questions.map(&:id)).to eq(%w[relat4]) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct id" do |
||||||
|
expect(page.id).to eq("person_4_relationship_to_buyer_1") |
||||||
|
end |
||||||
|
|
||||||
|
it "has correct depends_on" do |
||||||
|
expect(page.depends_on).to eq([{ "details_known_4" => 1 }]) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context "with person 5" do |
||||||
|
let(:person_index) { 5 } |
||||||
|
let(:page_id) { "person_5_relationship_to_buyer_1" } |
||||||
|
|
||||||
|
it "has correct questions" do |
||||||
|
expect(page.questions.map(&:id)).to eq(%w[relat5]) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct id" do |
||||||
|
expect(page.id).to eq("person_5_relationship_to_buyer_1") |
||||||
|
end |
||||||
|
|
||||||
|
it "has correct depends_on" do |
||||||
|
expect(page.depends_on).to eq([{ "details_known_5" => 1 }]) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,43 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe Form::Sales::Questions::Buyer2RelationshipToBuyer1YesNo, type: :model do |
||||||
|
subject(:question) { described_class.new(question_id, question_definition, page) } |
||||||
|
|
||||||
|
let(:question_id) { 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(2025, 4, 1)))) } |
||||||
|
|
||||||
|
it "has correct page" do |
||||||
|
expect(question.page).to eq(page) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct id" do |
||||||
|
expect(question.id).to eq("relat2") |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct type" do |
||||||
|
expect(question.type).to eq("radio") |
||||||
|
end |
||||||
|
|
||||||
|
it "is not marked as derived" do |
||||||
|
expect(question.derived?(nil)).to be false |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct answer_options" do |
||||||
|
expect(question.answer_options).to eq({ |
||||||
|
"P" => { "value" => "Yes" }, |
||||||
|
"X" => { "value" => "No" }, |
||||||
|
"R" => { "value" => "Buyer prefers not to say" }, |
||||||
|
}) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct check_answers_card_number" do |
||||||
|
expect(question.check_answers_card_number).to eq(2) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct inferred_check_answers_value" do |
||||||
|
expect(question.inferred_check_answers_value).to eq([ |
||||||
|
{ "condition" => { "relat2" => "R" }, "value" => "Prefers not to say" }, |
||||||
|
]) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,110 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe Form::Sales::Questions::PersonRelationshipToBuyer1YesNo, type: :model do |
||||||
|
subject(:question) { described_class.new(question_id, question_definition, page, person_index:) } |
||||||
|
|
||||||
|
let(:question_id) { "relat2" } |
||||||
|
let(:question_definition) { nil } |
||||||
|
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1)))) } |
||||||
|
let(:person_index) { 2 } |
||||||
|
|
||||||
|
it "has correct page" do |
||||||
|
expect(question.page).to eq(page) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct type" do |
||||||
|
expect(question.type).to eq("radio") |
||||||
|
end |
||||||
|
|
||||||
|
it "is not marked as derived" do |
||||||
|
expect(question.derived?(nil)).to be false |
||||||
|
end |
||||||
|
|
||||||
|
it "has expected check answers card number" do |
||||||
|
expect(question.check_answers_card_number).to eq(2) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct answer_options" do |
||||||
|
expect(question.answer_options).to eq({ |
||||||
|
"P" => { "value" => "Yes" }, |
||||||
|
"X" => { "value" => "No" }, |
||||||
|
"R" => { "value" => "Person prefers not to say" }, |
||||||
|
}) |
||||||
|
end |
||||||
|
|
||||||
|
context "when person 2" do |
||||||
|
let(:question_id) { "relat2" } |
||||||
|
let(:person_index) { 2 } |
||||||
|
|
||||||
|
it "has the correct id" do |
||||||
|
expect(question.id).to eq("relat2") |
||||||
|
end |
||||||
|
|
||||||
|
it "has expected check answers card number" do |
||||||
|
expect(question.check_answers_card_number).to eq(2) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct inferred_check_answers_value" do |
||||||
|
expect(question.inferred_check_answers_value).to eq([ |
||||||
|
{ "condition" => { "relat2" => "R" }, "value" => "Prefers not to say" }, |
||||||
|
]) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context "when person 3" do |
||||||
|
let(:question_id) { "relat3" } |
||||||
|
let(:person_index) { 3 } |
||||||
|
|
||||||
|
it "has the correct id" do |
||||||
|
expect(question.id).to eq("relat3") |
||||||
|
end |
||||||
|
|
||||||
|
it "has expected check answers card number" do |
||||||
|
expect(question.check_answers_card_number).to eq(3) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct inferred_check_answers_value" do |
||||||
|
expect(question.inferred_check_answers_value).to eq([ |
||||||
|
{ "condition" => { "relat3" => "R" }, "value" => "Prefers not to say" }, |
||||||
|
]) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context "when person 4" do |
||||||
|
let(:question_id) { "relat4" } |
||||||
|
let(:person_index) { 4 } |
||||||
|
|
||||||
|
it "has the correct id" do |
||||||
|
expect(question.id).to eq("relat4") |
||||||
|
end |
||||||
|
|
||||||
|
it "has expected check answers card number" do |
||||||
|
expect(question.check_answers_card_number).to eq(4) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct inferred_check_answers_value" do |
||||||
|
expect(question.inferred_check_answers_value).to eq([ |
||||||
|
{ "condition" => { "relat4" => "R" }, "value" => "Prefers not to say" }, |
||||||
|
]) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context "when person 5" do |
||||||
|
let(:question_id) { "relat5" } |
||||||
|
let(:person_index) { 5 } |
||||||
|
|
||||||
|
it "has the correct id" do |
||||||
|
expect(question.id).to eq("relat5") |
||||||
|
end |
||||||
|
|
||||||
|
it "has expected check answers card number" do |
||||||
|
expect(question.check_answers_card_number).to eq(5) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct inferred_check_answers_value" do |
||||||
|
expect(question.inferred_check_answers_value).to eq([ |
||||||
|
{ "condition" => { "relat5" => "R" }, "value" => "Prefers not to say" }, |
||||||
|
]) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue