From 5683fa5aab37500e411c1ae5aab6704470a27d42 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Thu, 22 Dec 2022 09:44:34 +0000 Subject: [PATCH] test: add tests --- .../form/sales/pages/about_deposit_spec.rb | 33 +++++++++++++ .../sales/questions/deposit_amount_spec.rb | 49 +++++++++++++++++++ .../sales/questions/deposit_discount_spec.rb | 49 +++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 spec/models/form/sales/pages/about_deposit_spec.rb create mode 100644 spec/models/form/sales/questions/deposit_amount_spec.rb create mode 100644 spec/models/form/sales/questions/deposit_discount_spec.rb diff --git a/spec/models/form/sales/pages/about_deposit_spec.rb b/spec/models/form/sales/pages/about_deposit_spec.rb new file mode 100644 index 000000000..e22cf1e76 --- /dev/null +++ b/spec/models/form/sales/pages/about_deposit_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::AboutDeposit, 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) } + + 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[deposit cashdis]) + end + + it "has the correct id" do + expect(page.id).to eq(nil) + end + + it "has the correct header" do + expect(page.header).to eq("About the deposit") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct depends_on" do + expect(page.depends_on).to be_nil + end +end diff --git a/spec/models/form/sales/questions/deposit_amount_spec.rb b/spec/models/form/sales/questions/deposit_amount_spec.rb new file mode 100644 index 000000000..9eaa628cf --- /dev/null +++ b/spec/models/form/sales/questions/deposit_amount_spec.rb @@ -0,0 +1,49 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::DepositAmount, 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) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("deposit") + end + + it "has the correct header" do + expect(question.header).to eq("How much cash deposit was paid on the property?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Cash deposit") + 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 eq("Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage") + end + + it "has correct width" do + expect(question.width).to eq(5) + end + + it "has correct prefix" do + expect(question.prefix).to eq("£") + end + + it "has correct min" do + expect(question.min).to eq(0) + end +end diff --git a/spec/models/form/sales/questions/deposit_discount_spec.rb b/spec/models/form/sales/questions/deposit_discount_spec.rb new file mode 100644 index 000000000..54675f98e --- /dev/null +++ b/spec/models/form/sales/questions/deposit_discount_spec.rb @@ -0,0 +1,49 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::DepositDiscount, 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) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("cashdis") + end + + it "has the correct header" do + expect(question.header).to eq("How much cash discount was given through Social HomeBuy?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Monthly rent") + 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 eq("Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme") + end + + it "has correct width" do + expect(question.width).to eq(5) + end + + it "has correct prefix" do + expect(question.prefix).to eq("£") + end + + it "has correct min" do + expect(question.min).to eq(0) + end +end