diff --git a/spec/models/form/lettings/pages/person2_age_spec.rb b/spec/models/form/lettings/pages/person2_age_spec.rb new file mode 100644 index 000000000..32f51b69c --- /dev/null +++ b/spec/models/form/lettings/pages/person2_age_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::Person2Age, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "person_2_age" } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to eq("") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[age2_known age2]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_age") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "details_known_2" => 0 }], + ) + end +end diff --git a/spec/models/form/lettings/pages/person3_age_spec.rb b/spec/models/form/lettings/pages/person3_age_spec.rb new file mode 100644 index 000000000..c764dd695 --- /dev/null +++ b/spec/models/form/lettings/pages/person3_age_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::Person3Age, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "person_3_age" } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to eq("") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[age3_known age3]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_age") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{"details_known_3"=>0}], + ) + end +end \ No newline at end of file diff --git a/spec/models/form/lettings/pages/person4_age_spec.rb b/spec/models/form/lettings/pages/person4_age_spec.rb new file mode 100644 index 000000000..df825984e --- /dev/null +++ b/spec/models/form/lettings/pages/person4_age_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::Person4Age, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "person_4_age" } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to eq("") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[age4_known age4]) + end + + it "has the correct id" do + expect(page.id).to eq("person_4_age") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "details_known_4" => 0 }], + ) + end +end diff --git a/spec/models/form/lettings/pages/person5_age_spec.rb b/spec/models/form/lettings/pages/person5_age_spec.rb new file mode 100644 index 000000000..238346d52 --- /dev/null +++ b/spec/models/form/lettings/pages/person5_age_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::Person5Age, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "person_5_age" } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to eq("") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[age5_known age5]) + end + + it "has the correct id" do + expect(page.id).to eq("person_5_age") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "details_known_5" => 0 }], + ) + end +end diff --git a/spec/models/form/lettings/pages/person6_age_spec.rb b/spec/models/form/lettings/pages/person6_age_spec.rb new file mode 100644 index 000000000..567b15ed4 --- /dev/null +++ b/spec/models/form/lettings/pages/person6_age_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::Person6Age, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "person_6_age" } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to eq("") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[age6_known age6]) + end + + it "has the correct id" do + expect(page.id).to eq("person_6_age") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{"details_known_6"=>0}], + ) + end +end \ No newline at end of file diff --git a/spec/models/form/lettings/pages/person7_age_spec.rb b/spec/models/form/lettings/pages/person7_age_spec.rb new file mode 100644 index 000000000..3d0cf271e --- /dev/null +++ b/spec/models/form/lettings/pages/person7_age_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::Person7Age, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "person_7_age" } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to eq("") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[age7_known age7]) + end + + it "has the correct id" do + expect(page.id).to eq("person_7_age") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{"details_known_7"=>0}], + ) + end +end \ No newline at end of file diff --git a/spec/models/form/lettings/pages/person8_age_spec.rb b/spec/models/form/lettings/pages/person8_age_spec.rb new file mode 100644 index 000000000..1227328f1 --- /dev/null +++ b/spec/models/form/lettings/pages/person8_age_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::Person8Age, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "person_8_age" } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to eq("") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[age8_known age8]) + end + + it "has the correct id" do + expect(page.id).to eq("person_8_age") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{"details_known_8"=>0}], + ) + end +end \ No newline at end of file diff --git a/spec/models/form/lettings/questions/age2_known_spec.rb b/spec/models/form/lettings/questions/age2_known_spec.rb new file mode 100644 index 000000000..ba6ba7485 --- /dev/null +++ b/spec/models/form/lettings/questions/age2_known_spec.rb @@ -0,0 +1,73 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age2Known, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age2_known" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + before do + allow(page).to receive(:id).and_return("age2_known") + end + + 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?).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has the correct id" do + expect(question.id).to eq("age2_known") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know person 2’s age?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("") + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "age2" => [0], + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq( + { + "depends_on" => [ + { + "age2_known" => 0, + }, + { + "age2_known" => 1, + }, + ], + }, + ) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(2) + end +end diff --git a/spec/models/form/lettings/questions/age2_spec.rb b/spec/models/form/lettings/questions/age2_spec.rb new file mode 100644 index 000000000..d40c9276b --- /dev/null +++ b/spec/models/form/lettings/questions/age2_spec.rb @@ -0,0 +1,60 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age2, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age2" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct header" do + expect(question.header).to eq("Age") + end + + it "has the correct type" do + expect(question.type).to eq("numeric") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has the correct min" do + expect(question.min).to eq(0) + end + + it "has the correct max" do + expect(question.max).to eq(120) + end + + it "has the correct id" do + expect(question.id).to eq("age2") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 2’s age") + end + + it "has the correct width" do + expect(question.width).to eq(2) + end + + it "has the correct inferred check answers value" do + expect(question.inferred_check_answers_value).to eq([{ + "condition" => { "age2_known" => 1 }, + "value" => "Not known", + }]) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(2) + end +end diff --git a/spec/models/form/lettings/questions/age3_known_spec.rb b/spec/models/form/lettings/questions/age3_known_spec.rb new file mode 100644 index 000000000..b23720e56 --- /dev/null +++ b/spec/models/form/lettings/questions/age3_known_spec.rb @@ -0,0 +1,73 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age3Known, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age3_known" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + before do + allow(page).to receive(:id).and_return("age3_known") + end + + 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?).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has the correct id" do + expect(question.id).to eq("age3_known") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know person 3’s age?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("") + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "age3" => [0], + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq( + { + "depends_on" => [ + { + "age3_known" => 0, + }, + { + "age3_known" => 1, + }, + ], + }, + ) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(3) + end +end diff --git a/spec/models/form/lettings/questions/age3_spec.rb b/spec/models/form/lettings/questions/age3_spec.rb new file mode 100644 index 000000000..6b0dcc36a --- /dev/null +++ b/spec/models/form/lettings/questions/age3_spec.rb @@ -0,0 +1,60 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age3, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age3" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct header" do + expect(question.header).to eq("Age") + end + + it "has the correct type" do + expect(question.type).to eq("numeric") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has the correct min" do + expect(question.min).to eq(0) + end + + it "has the correct max" do + expect(question.max).to eq(120) + end + + it "has the correct id" do + expect(question.id).to eq("age3") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 3’s age") + end + + it "has the correct width" do + expect(question.width).to eq(2) + end + + it "has the correct inferred check answers value" do + expect(question.inferred_check_answers_value).to eq([{ + "condition" => { "age3_known" => 1 }, + "value" => "Not known", + }]) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(3) + end +end diff --git a/spec/models/form/lettings/questions/age4_known_spec.rb b/spec/models/form/lettings/questions/age4_known_spec.rb new file mode 100644 index 000000000..498ee40de --- /dev/null +++ b/spec/models/form/lettings/questions/age4_known_spec.rb @@ -0,0 +1,73 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age4Known, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age4_known" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + before do + allow(page).to receive(:id).and_return("age4_known") + end + + 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?).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has the correct id" do + expect(question.id).to eq("age4_known") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know person 4’s age?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("") + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "age4" => [0], + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq( + { + "depends_on" => [ + { + "age4_known" => 0, + }, + { + "age4_known" => 1, + }, + ], + }, + ) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(4) + end +end diff --git a/spec/models/form/lettings/questions/age4_spec.rb b/spec/models/form/lettings/questions/age4_spec.rb new file mode 100644 index 000000000..7c6b6c6c2 --- /dev/null +++ b/spec/models/form/lettings/questions/age4_spec.rb @@ -0,0 +1,60 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age4, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age4" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct header" do + expect(question.header).to eq("Age") + end + + it "has the correct type" do + expect(question.type).to eq("numeric") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has the correct min" do + expect(question.min).to eq(0) + end + + it "has the correct max" do + expect(question.max).to eq(120) + end + + it "has the correct id" do + expect(question.id).to eq("age4") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 4’s age") + end + + it "has the correct width" do + expect(question.width).to eq(2) + end + + it "has the correct inferred check answers value" do + expect(question.inferred_check_answers_value).to eq([{ + "condition" => { "age4_known" => 1 }, + "value" => "Not known", + }]) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(4) + end +end diff --git a/spec/models/form/lettings/questions/age5_known_spec.rb b/spec/models/form/lettings/questions/age5_known_spec.rb new file mode 100644 index 000000000..2dbb3733b --- /dev/null +++ b/spec/models/form/lettings/questions/age5_known_spec.rb @@ -0,0 +1,73 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age5Known, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age5_known" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + before do + allow(page).to receive(:id).and_return("age5_known") + end + + 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?).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has the correct id" do + expect(question.id).to eq("age5_known") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know person 5’s age?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("") + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "age5" => [0], + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq( + { + "depends_on" => [ + { + "age5_known" => 0, + }, + { + "age5_known" => 1, + }, + ], + }, + ) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(5) + end +end diff --git a/spec/models/form/lettings/questions/age5_spec.rb b/spec/models/form/lettings/questions/age5_spec.rb new file mode 100644 index 000000000..074f836f5 --- /dev/null +++ b/spec/models/form/lettings/questions/age5_spec.rb @@ -0,0 +1,60 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age5, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age5" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct header" do + expect(question.header).to eq("Age") + end + + it "has the correct type" do + expect(question.type).to eq("numeric") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has the correct min" do + expect(question.min).to eq(0) + end + + it "has the correct max" do + expect(question.max).to eq(120) + end + + it "has the correct id" do + expect(question.id).to eq("age5") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 5’s age") + end + + it "has the correct width" do + expect(question.width).to eq(2) + end + + it "has the correct inferred check answers value" do + expect(question.inferred_check_answers_value).to eq([{ + "condition" => { "age5_known" => 1 }, + "value" => "Not known", + }]) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(5) + end +end diff --git a/spec/models/form/lettings/questions/age6_known_spec.rb b/spec/models/form/lettings/questions/age6_known_spec.rb new file mode 100644 index 000000000..ed9aa247d --- /dev/null +++ b/spec/models/form/lettings/questions/age6_known_spec.rb @@ -0,0 +1,73 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age6Known, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age6_known" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + before do + allow(page).to receive(:id).and_return("age6_known") + end + + 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?).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has the correct id" do + expect(question.id).to eq("age6_known") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know person 6’s age?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("") + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "age6" => [0], + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq( + { + "depends_on" => [ + { + "age6_known" => 0, + }, + { + "age6_known" => 1, + }, + ], + }, + ) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(6) + end +end diff --git a/spec/models/form/lettings/questions/age6_spec.rb b/spec/models/form/lettings/questions/age6_spec.rb new file mode 100644 index 000000000..2aedbe7e3 --- /dev/null +++ b/spec/models/form/lettings/questions/age6_spec.rb @@ -0,0 +1,60 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age6, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age6" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct header" do + expect(question.header).to eq("Age") + end + + it "has the correct type" do + expect(question.type).to eq("numeric") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has the correct min" do + expect(question.min).to eq(0) + end + + it "has the correct max" do + expect(question.max).to eq(120) + end + + it "has the correct id" do + expect(question.id).to eq("age6") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 6’s age") + end + + it "has the correct width" do + expect(question.width).to eq(2) + end + + it "has the correct inferred check answers value" do + expect(question.inferred_check_answers_value).to eq([{ + "condition" => { "age6_known" => 1 }, + "value" => "Not known", + }]) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(6) + end +end diff --git a/spec/models/form/lettings/questions/age7_known_spec.rb b/spec/models/form/lettings/questions/age7_known_spec.rb new file mode 100644 index 000000000..43a83df61 --- /dev/null +++ b/spec/models/form/lettings/questions/age7_known_spec.rb @@ -0,0 +1,73 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age7Known, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age7_known" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + before do + allow(page).to receive(:id).and_return("age7_known") + end + + 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?).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has the correct id" do + expect(question.id).to eq("age7_known") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know person 7’s age?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("") + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "age7" => [0], + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq( + { + "depends_on" => [ + { + "age7_known" => 0, + }, + { + "age7_known" => 1, + }, + ], + }, + ) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(7) + end +end diff --git a/spec/models/form/lettings/questions/age7_spec.rb b/spec/models/form/lettings/questions/age7_spec.rb new file mode 100644 index 000000000..6586d488e --- /dev/null +++ b/spec/models/form/lettings/questions/age7_spec.rb @@ -0,0 +1,60 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age7, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age7" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct header" do + expect(question.header).to eq("Age") + end + + it "has the correct type" do + expect(question.type).to eq("numeric") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has the correct min" do + expect(question.min).to eq(0) + end + + it "has the correct max" do + expect(question.max).to eq(120) + end + + it "has the correct id" do + expect(question.id).to eq("age7") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 7’s age") + end + + it "has the correct width" do + expect(question.width).to eq(2) + end + + it "has the correct inferred check answers value" do + expect(question.inferred_check_answers_value).to eq([{ + "condition" => { "age7_known" => 1 }, + "value" => "Not known", + }]) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(7) + end +end diff --git a/spec/models/form/lettings/questions/age8_known_spec.rb b/spec/models/form/lettings/questions/age8_known_spec.rb new file mode 100644 index 000000000..e2ad50732 --- /dev/null +++ b/spec/models/form/lettings/questions/age8_known_spec.rb @@ -0,0 +1,73 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age8Known, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age8_known" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + before do + allow(page).to receive(:id).and_return("age8_known") + end + + 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?).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has the correct id" do + expect(question.id).to eq("age8_known") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know person 8’s age?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("") + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "age8" => [0], + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq( + { + "depends_on" => [ + { + "age8_known" => 0, + }, + { + "age8_known" => 1, + }, + ], + }, + ) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(8) + end +end diff --git a/spec/models/form/lettings/questions/age8_spec.rb b/spec/models/form/lettings/questions/age8_spec.rb new file mode 100644 index 000000000..e08f589d0 --- /dev/null +++ b/spec/models/form/lettings/questions/age8_spec.rb @@ -0,0 +1,60 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age8, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "age8" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct header" do + expect(question.header).to eq("Age") + end + + it "has the correct type" do + expect(question.type).to eq("numeric") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has the correct min" do + expect(question.min).to eq(0) + end + + it "has the correct max" do + expect(question.max).to eq(120) + end + + it "has the correct id" do + expect(question.id).to eq("age8") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 8’s age") + end + + it "has the correct width" do + expect(question.width).to eq(2) + end + + it "has the correct inferred check answers value" do + expect(question.inferred_check_answers_value).to eq([{ + "condition" => { "age8_known" => 1 }, + "value" => "Not known", + }]) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(8) + end +end